A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Order Entry Form



 
 
Thread Tools Display Modes
  #1  
Old April 22nd, 2008, 08:06 PM posted to microsoft.public.access.gettingstarted
shannaj via AccessMonster.com
external usenet poster
 
Posts: 35
Default 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  
Old April 22nd, 2008, 08:22 PM posted to microsoft.public.access.gettingstarted
Ray C
external usenet poster
 
Posts: 215
Default 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  
Old April 22nd, 2008, 10:21 PM posted to microsoft.public.access.gettingstarted
shannaj via AccessMonster.com
external usenet poster
 
Posts: 35
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:16 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.