473,508 Members | 2,412 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help with DLookup/ I'm stumped!

Don
Can someone help me fix my DLookup problem. I'm far from proficiency with
Access. I've been creating databases for several years for work with the
help of many of you and trial and error.
I have used DLookup several times and I've actually re-created the same
lookup just in different forms.
Here's my problem.
I'm using dlookup when I enter a part description it adds the part number
for me. I choose the part description from a combo box. This is how I've
done it several times in other tables.
In all the other instances when I enter the part description and move to the
next control (?term), or hit enter, the part number appears. In my present
situation the part number doesn't appear until after I've moved to the next
record. I'm using an Event Procedure in the AfterUpdate control (?term) as
I've done in all the other instances. It's just that this one works
differently.
Can anyone tell me why? I realize that there's probably more I should tell
you but I don't know what that is. If you ask me for more info I'll do my
best to provide it. Here's the code I'm using:
Thanks,
Don............

Private Sub Casting_AfterUpdate()
On Error GoTo Err_Casting_AfterUpdate

Dim strFiter As String

'Evaluate filter before it's passed to DLookup function.
strFilter = "Casting = " & Me!Casting

'Look up castings partID and assign it to part# control.
Me!PartID = DLookup("[PartID]", "Casting Table", "[Casting] = '" &
Me!Casting & "'")

Exit_Casting_AfterUpdate:
Exit Sub

Err_Casting_AfterUpdate:
MsgBox Err.Description
Resume Exit_Casting_AfterUpdate

End Sub
May 5 '06 #1
2 2263
It looks like you might do better with a 2 column combo box. The first
column will hold the partID and the second column will be the description.
When you set up the combo box, in the properties dialog, under format, set
column count to 2, then for the rowsource of the combo box use something
like "select partID, Description from [Casting Table]. In the column widths
for the combo box (also under format), you can say 0;4 (these are inches),
and the first column will be invisible. (or if you don't want it invisible,
give the first column a nonzero width, so something like 1;4) Then set the
bound column (under data) property to 1, and the combo box will actually
store the partID even though all you see is the description. Then set the
control source of the combobox to be PartID.
hope this helps
-John

"Don" <vz******@verizon.net> wrote in message
news:wHw6g.922$0v6.1@trndny05...
Can someone help me fix my DLookup problem. I'm far from proficiency with
Access. I've been creating databases for several years for work with the
help of many of you and trial and error.
I have used DLookup several times and I've actually re-created the same
lookup just in different forms.
Here's my problem.
I'm using dlookup when I enter a part description it adds the part number
for me. I choose the part description from a combo box. This is how I've
done it several times in other tables.
In all the other instances when I enter the part description and move to
the
next control (?term), or hit enter, the part number appears. In my
present
situation the part number doesn't appear until after I've moved to the
next
record. I'm using an Event Procedure in the AfterUpdate control (?term)
as
I've done in all the other instances. It's just that this one works
differently.
Can anyone tell me why? I realize that there's probably more I should
tell
you but I don't know what that is. If you ask me for more info I'll do my
best to provide it. Here's the code I'm using:
Thanks,
Don............

Private Sub Casting_AfterUpdate()
On Error GoTo Err_Casting_AfterUpdate

Dim strFiter As String

'Evaluate filter before it's passed to DLookup function.
strFilter = "Casting = " & Me!Casting

'Look up castings partID and assign it to part# control.
Me!PartID = DLookup("[PartID]", "Casting Table", "[Casting] = '" &
Me!Casting & "'")

Exit_Casting_AfterUpdate:
Exit Sub

Err_Casting_AfterUpdate:
MsgBox Err.Description
Resume Exit_Casting_AfterUpdate

End Sub

May 5 '06 #2

"Don" <vz******@verizon.net> schreef in bericht news:wHw6g.922$0v6.1@trndny05...
Can someone help me fix my DLookup problem. I'm far from proficiency with
Access. I've been creating databases for several years for work with the
help of many of you and trial and error.
I have used DLookup several times and I've actually re-created the same
lookup just in different forms.
Here's my problem.
I'm using dlookup when I enter a part description it adds the part number
for me. I choose the part description from a combo box. This is how I've
done it several times in other tables.
In all the other instances when I enter the part description and move to the
next control (?term), or hit enter, the part number appears. In my present
situation the part number doesn't appear until after I've moved to the next
record. I'm using an Event Procedure in the AfterUpdate control (?term) as
I've done in all the other instances. It's just that this one works
differently.
Can anyone tell me why? I realize that there's probably more I should tell
you but I don't know what that is. If you ask me for more info I'll do my
best to provide it. Here's the code I'm using:
Thanks,
Don............

Private Sub Casting_AfterUpdate()
On Error GoTo Err_Casting_AfterUpdate

Dim strFiter As String

'Evaluate filter before it's passed to DLookup function.
strFilter = "Casting = " & Me!Casting

'Look up castings partID and assign it to part# control.
Me!PartID = DLookup("[PartID]", "Casting Table", "[Casting] = '" &
Me!Casting & "'")

Exit_Casting_AfterUpdate:
Exit Sub

Err_Casting_AfterUpdate:
MsgBox Err.Description
Resume Exit_Casting_AfterUpdate

End Sub


The code should work IMO, but please check a few things:
-- You create a var like strFilter but you are not actually using strFilter.
Also strFilter is wrong (Casting seems to be a string, so needs extra quotes)
-- If you were to use strFilter indeed you could use code like:
Me!PartID = DLookup("[PartID]", "Casting Table", strFilter)
-- In that case strFilter needs to be changed to:
strFilter = "[Casting] = '" & Me!Casting & "'" (like you do in the where clause of DLookup)
In that case for clarity I would also use another name like strWhere instead of strFilter

So maybe I would use code like:

Private Sub Casting_AfterUpdate()
On Error GoTo Err_Casting_AfterUpdate

Dim strWhere As String
'Evaluate before it's passed to DLookup function.
strWhere = "[Casting] = '" & Me!Casting & "'"

'Look up castings partID and assign it to part# control.
Me!PartID = DLookup("[PartID]", "Casting Table", strWhere)
Exit_Casting_AfterUpdate:
Exit Sub

Err_Casting_AfterUpdate:
MsgBox Err.Description
Resume Exit_Casting_AfterUpdate

End Sub
BUT your code is not working....
-Is Me!PartID the name of your control or ?? (try changing the name)
Is this control (PartID) bound or unbound ??
-If you test the DLookup in the Immediate window what does it say ??

Arno R
May 5 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
3184
by: Kalvin Schroder | last post by:
I am fairly new to Access, and am trying to put together an invoice form. The main form in called InvoiceDetailFm. Source is the table InvoiceDetail and has invoice number, saleman, and CustID as...
3
4197
by: Tempy | last post by:
Hi all, i am running into problems with a DLookUp below: =DLookUp("","tblBuyerTotals"," =' " & me!LastName) This is in the Control Source of a text box on the same form. "LastName" is a text...
4
2482
by: basstwo | last post by:
I have a field with a serial number in it. I want to use Mid to extract the 4th and 5th characters, use them to lookup a value on a small lookup table, and use the info from that table to fill in...
5
2319
by: kevinjouco | last post by:
Hello Have searched the group for a solution to the following problem without success: Table 1 has Ref No (No Duplicates) & Min Max Value Fields ie Ref No 1 Min 1 Max 10 Ref No 2 Min 11 Max...
6
508
by: Don Sealer | last post by:
I've written this expression for a DLookup function. It works almost alright. What I'm trying to do is type in a description and the ID field (number) populates automatically. It works almost as...
6
5778
by: deejayquai | last post by:
Hi I'm attempting to append multiple values into a new record, using multiple criteria from a listbox. I've got the basics for the code below but I get an "Error 3085 Undefined Function" for...
21
3325
by: Thelma Lubkin | last post by:
I would like my DLookup criteria to say this: Trim(fieldX) = strVar: myVar = _ DLookup("someField", "someTable", "Trim(fieldX) = '" & strVar & '") I don't believe that this will work, and I...
2
1530
by: Simon | last post by:
Hi, I need some help form someone. I use my database for my online shop, so once I have entered a order onto the database I have a button that creates the Email to the customer to let them know...
1
1785
by: aharding | last post by:
Hello! I am using Access 2003 I have been playing with DLookup all morning and have not been successful yet. I have never used this function...and have some limited experience with code. I...
0
7321
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7377
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7036
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7489
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5047
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1547
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.