If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Order Entry Form
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 -- Message posted via http://www.accessmonster.com |
#2
|
|||
|
|||
Order Entry Form
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 & """" "shannaj via AccessMonster.com" wrote: 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 -- Message posted via http://www.accessmonster.com |
#3
|
|||
|
|||
Order Entry Form
Thank you so much! That worked great!
Ray C wrote: 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 -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/For...arted/200804/1 |
Thread Tools | |
Display Modes | |
|
|