Order Entry Form

  • Thread starter shannaj via AccessMonster.com
  • Start date
S

shannaj via AccessMonster.com

I have an order entry form with the following in code for AfterUpdate on my
ItemID. I copied it from the northwind sample database. What I am trying to
accomplish is when the Item Id is entered, I want it to pull the price from
the Items table, but if the price is changed, I want it to be reflected in
the Itemdetails table. The form I am using is created from a query, just
like the northwind database. The problem I am having is that when I run this,
I am getting the following message: Syntax error (missing operator) in query
expression 'ItemID=BMD 1002-01' Can someone please shed some light in to
what I am doing wrong?

Private Sub ItemID_AfterUpdate()
On Error GoTo Err_ItemID_AfterUpdate

Dim strFilter As String

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

' Look up product's unit price and assign it to UnitPrice control.
Me!UnitPrice = DLookup("UnitPrice", "tblItemList", strFilter)

Exit_ItemID_AfterUpdate:
Exit Sub

Err_ItemID_AfterUpdate:
MsgBox Err.Description
Resume Exit_ItemID_AfterUpdate
 
R

Ray C

Upon first glance, it looks like your ItemID is of type Text. So that means
you have to enclose your filter inside single quotes, like so:

strFilter = "ItemID = '" & Me!ItemID & "'"

or you can do what I always do, enclose them in double quotes

strFilter = "ItemID = " & """" & Me!ItemID & """"
 
S

shannaj via AccessMonster.com

Thank you so much! That worked great!

Ray said:
Upon first glance, it looks like your ItemID is of type Text. So that means
you have to enclose your filter inside single quotes, like so:

strFilter = "ItemID = '" & Me!ItemID & "'"

or you can do what I always do, enclose them in double quotes

strFilter = "ItemID = " & """" & Me!ItemID & """"
I have an order entry form with the following in code for AfterUpdate on my
ItemID. I copied it from the northwind sample database. What I am trying to
[quoted text clipped - 23 lines]
MsgBox Err.Description
Resume Exit_ItemID_AfterUpdate
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top