Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I have the following code in the Af

Status
Not open for further replies.

ascheper

Technical User
Nov 29, 2001
45
CA
I have the following code in the After_Update event of a field on my customer form. Each time the code runs I get a run-time error 2757, There was a problem accessing a property or method of the OLE object. When I go to debug, the Dlookup rows are the source of the errors. I use Dlookup on the same form, with the same syntax and it works fine. Any help would be greatly appreciated.

Dim frmCurrentForm As Form
Dim FormCity As String
Dim FormPostal As String
Dim LookCity As String
Dim LookPostal As String
Dim BeyondCode As Integer

'DLookup("[ProductName]", "Products", "[ProductID] =" & Forms![Order Details]!ProductID) EG

Set frmCurrentForm = Screen.ActiveForm

FormCity = frmCurrentForm.City
FormPostal = Left(frmCurrentForm.PostalCode, 3)

LookCity = DLookup("[City]", "SHIPPING_RATE_CHECK", "[City]=" & FormCity)

LookPostal = DLookup("[PostalPrefix]", "SHIPPING_RATE_CHECK", "[City]=" & FormCity)

BeyondCode = DLookup("[BeyondCode]", "SHIPPING_RATE_CHECK", "[City]=" & FormCity)

If BeyondCode > 2 Then

Me.shippingcharges = "THIS ORDER REQUIRES ADDITIONAL SHIPPING CHARGES. PLEASE SEE KEITH FOR RATES"

Else

Me.shippingcharges = "REGULAR SHIPPING CHARGES"

End If
 
This may or may not be causing your problem, but it seems like FormCity should be enclosed in quotes. You might try this:

LookCity = DLookup("[City]", "SHIPPING_RATE_CHECK", "[City]=" & Chr(34) & FormCity & Chr(34))

or

LookCity = DLookup("[City]", "SHIPPING_RATE_CHECK", "[City]='" & FormCity & "'")

You would make a similar change to the other DLookup statements that have a string in the criteria argument.

dz
dzaccess@yahoo.com
 
Thank you, I'll give that a try tomorrow and see if it works.
 
If city is common why not use JOINS and a comobo box to get them all at once?

rollie@bwsys.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top