Issue with Dlookup- Help Please! (1 Viewer)

eocean234

New member
Local time
Today, 13:03
Joined
Mar 25, 2024
Messages
8
Hi I am new to access and trying to include a Dlookup in my coursework but I can't seem to get it working, I keep getting #Error. Its just to lookup a value in a table. Any help appreciated!:)
 

Attachments

  • Issue.png
    Issue.png
    21.8 KB · Views: 32

plog

Banishment Pending
Local time
Today, 07:03
Joined
May 11, 2011
Messages
11,646
Only use alphanumeric characters and underscores in names. When you put spaces in them (Exam ID), it makes you need an additional step when working with them. That step is surrounding the name in brackets. So put brackets around Exam ID in the Dlookup ([Exam ID]). Or better yet, fix all your names to comply with the rule above.
 

eocean234

New member
Local time
Today, 13:03
Joined
Mar 25, 2024
Messages
8
Only use alphanumeric characters and underscores in names. When you put spaces in them (Exam ID), it makes you need an additional step when working with them. That step is surrounding the name in brackets. So put brackets around Exam ID in the Dlookup ([Exam ID]). Or better yet, fix all your names to comply with the rule above.
Hi thank you for the help but I am still a bit confused, I've tried and will insert below. I am still getting an error.
 

Attachments

  • issue2.png
    issue2.png
    9.3 KB · Views: 22
  • issue3.png
    issue3.png
    6.6 KB · Views: 21

plog

Banishment Pending
Local time
Today, 07:03
Joined
May 11, 2011
Messages
11,646
Are your ExamID's text? Is 'Trinity' a value in ExamID? You need to treat text differently than numbers when you build the DLookup. You need to surround the value from the form in single quotes like so:

Code:
=Dlookup("Grade", "TblExam", "ExamID='" & Combo25 & "'")
 

LarryE

Active member
Local time
Today, 05:03
Joined
Aug 18, 2021
Messages
591
That DLookup does not have a clue what Combo25 is. So:
=DLookUp("Grade","TblExam","[ExamID]=Forms![FORM NAME]![Combo25]")
 

June7

AWF VIP
Local time
Today, 04:03
Joined
Mar 9, 2014
Messages
5,472
Why use DLookup()? Is this required for the exercise?

Embedding full path in the criteria will work, until you decided to use form as a subform and then the path is no longer correct and gets more complex.

Also, domain aggregate functions can slow performance with large datasets.

Include Grade in the combobox RowSource then reference that column by its index. If Grade is in third column, its index is 2: =Combo25.Column(2)

Don't use spaces nor special characters in naming convention, nor reserved words as names. Also, give controls more meaningful names.
 
Last edited:

mike60smart

Registered User.
Local time
Today, 13:03
Joined
Aug 6, 2017
Messages
1,905
Hi I am new to access and trying to include a Dlookup in my coursework but I can't seem to get it working, I keep getting #Error. Its just to lookup a value in a table. Any help appreciated!:)
Why is the Combobox Unbound ?

Normally the table would have a field named GradeID - Number datatype.

Then you would have a separate table that lists all of the Grades.

On your form you would create a Combobox and you would lookup the value you want from the Grades Table.
 

Gasman

Enthusiastic Amateur
Local time
Today, 13:03
Joined
Sep 21, 2011
Messages
14,305
Why is the Combobox Unbound ?

Normally the table would have a field named GradeID - Number datatype.

Then you would have a separate table that lists all of the Grades.

On your form you would create a Combobox and you would lookup the value you want from the Grades Table.
Search form?
 

eocean234

New member
Local time
Today, 13:03
Joined
Mar 25, 2024
Messages
8
That DLookup does not have a clue what Combo25 is. So:
=DLookUp("Grade","TblExam","[ExamID]=Forms![FORM NAME]![Combo25]")
I have tried this and the error message is gone but it appears blank
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 20:03
Joined
May 7, 2009
Messages
19,245
=DLookUp("Grade","TblExam","[ExamID]=" & Nz([Combo25], 0))
 

eocean234

New member
Local time
Today, 13:03
Joined
Mar 25, 2024
Messages
8
Hi back again, unfortunately I had to delete the table as I didn’t think I’d need it but now I do:(. So I’ve remade the table and form and now the dllook up only works when you try it once. Any help appreciated:))
 

Attachments

  • image.jpg
    image.jpg
    6.2 MB · Views: 11
  • image.jpg
    image.jpg
    5.9 MB · Views: 12

June7

AWF VIP
Local time
Today, 04:03
Joined
Mar 9, 2014
Messages
5,472
Can you provide db for analysis?
Follow instructions at bottom of my post.
 

eocean234

New member
Local time
Today, 13:03
Joined
Mar 25, 2024
Messages
8
Hi, I have it working now the problem was I had the combo box finding the values from another table or query instead of record on my form :)
I am now having problems with my DCount (sorry for being such a hassle) I wanted it to count the number of lessons that the member on my form is in but I am getting #Error. If anyone has any suggestions :)
 

Attachments

  • image.jpg
    image.jpg
    6.3 MB · Views: 14

Gasman

Enthusiastic Amateur
Local time
Today, 13:03
Joined
Sep 21, 2011
Messages
14,305
You have your parameters backwards, if I read your prefixes correctly.
Lookup the syntax. :(
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 08:03
Joined
May 21, 2018
Messages
8,529
Yes you have it backwards with the table name first
should always count "*" not a field name

dcount("*","table or queryName",Criteria)
 

Users who are viewing this thread

Top Bottom