DLookup Error (1 Viewer)

kbreiss

Registered User.
Local time
Today, 19:11
Joined
Oct 1, 2002
Messages
228
The following code below is producing this error....

"The macro of function set to the BeforeUpdate or ValidationRule property for this field is preventing Microsoft Access from saving the data in the field"

I know its blowing up on setting cboEventLocation.text But I don't know why. Any ideas?

txtEventAddress = DLookup("Location_Address", "tblLocation", "Location_Name = cboLocation ")
txtEventCity = DLookup("Location_City", "tblLocation", "Location_Name = cboLocation ")
medEventZip = DLookup("Location_Zip", "tblLocation", "Location_Name = cboLocation ")
cboEventCounty.SetFocus
cboEventCounty.Text = DLookup("Location_County", "tblLocation", "Location_Name = cboLocation ")
________
Oregon marijuana dispensary
 
Last edited:

RuralGuy

AWF VIP
Local time
Today, 12:11
Joined
Jul 2, 2005
Messages
13,826
It is probably the SetFocus you are using (which is necessary to mess with the Text property). What are you trying to accomplish? I assume we are in the BeforeUpdate event of the cboLocation ComboBox. Why not use the AfterUpdate event or the LostFocus event and Set the Focus where you need after leaving the cbo.
 

kbreiss

Registered User.
Local time
Today, 19:11
Joined
Oct 1, 2002
Messages
228
On Click

The code is in the On_Click event...I just tried it on the afterupdate event and I receive the same error...any suggestions?

Private Sub cboLocation_AfterUpdate()

'look up address
txtEventAddress = DLookup("Location_Address", "tblLocation", "Location_Name = cboLocation ")
txtEventCity = DLookup("Location_City", "tblLocation", "Location_Name = cboLocation ")
medEventZip = DLookup("Location_Zip", "tblLocation", "Location_Name = cboLocation ")
cboEventCounty.SetFocus
cboEventCounty.Text = DLookup("Location_County", "tblLocation", "Location_Name = cboLocation ")

End Sub
________
HALF-BAKED
 
Last edited:

kbreiss

Registered User.
Local time
Today, 19:11
Joined
Oct 1, 2002
Messages
228
A bit more information...
the cboEventCounty the row source for this is

SELECT DISTINCTROW [tblCounty].[ID], [tblCounty].[County] FROM [tblCounty] order by [tblCounty].[County];

So there is actually two columns in this cbo...would this make a difference?
________
Waterbongs
 
Last edited:
R

Rich

Guest
Why are you using DLookups at all? A query or even a calculated control would be far better and faster
 

richary

Registered User.
Local time
Today, 19:11
Joined
May 26, 2004
Messages
167
Try

txtEventAddress = DLookup("Location_Address", "tblLocation", "Location_Name = " & "'" & cboLocation & "')"

Agree with Rich, though. DLookups are usually to be avioded, if poss
 

kbreiss

Registered User.
Local time
Today, 19:11
Joined
Oct 1, 2002
Messages
228
Will try a query instead...I'm not familiar w/ dlookup, but that is good to know.
________
Slow Deepthroa
 
Last edited:

Users who are viewing this thread

Top Bottom