By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,569 Members | 1,386 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,569 IT Pros & Developers. It's quick & easy.

Syntax Error

P: n/a
Hello Access Monsters,

I have a table with three columns. "CostCenter", "ProjectNumber", "GLCode"
On my form I have three texboxes, "txtCostCenter", "txtProjectNumber" and
"txtGLCode".
the AfterUpdate event of the txtCostCenter runs the following code.

Me.txtProjectNumber = DLookup("ProjectNumber", "tblList", "CostCenter =" & Me.
txtCostCenter)
Me.txtGLCode = DLookup("GLCode", "tblList", "CostCenter =" & Me.txtCostCenter)
This works perfectly, however, sometimes the user may not have the CostCenter
so he will enter the ProjectNumber. Thus I have the AfterUpdate event of the
"txtProjectNumber" set to the following.

Me.txtGLCode = DLookup("GLCode", "tblList", "ProjectNumber =" & Me.
txtProjectNumber)

When entering the ProjectNumber I get the syntax error '3075' "syntax error
in number in query expression 'ProjectNumber = 4190740.1570003.00'

All my project numbers come in that format. Is it the format of the data
causing this?

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200709/1

Sep 5 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
injanib via AccessMonster.com wrote:
Hello Access Monsters,

I have a table with three columns. "CostCenter", "ProjectNumber", "GLCode"
On my form I have three texboxes, "txtCostCenter", "txtProjectNumber" and
"txtGLCode".
the AfterUpdate event of the txtCostCenter runs the following code.

Me.txtProjectNumber = DLookup("ProjectNumber", "tblList", "CostCenter =" & Me.
txtCostCenter)
Me.txtGLCode = DLookup("GLCode", "tblList", "CostCenter =" & Me.txtCostCenter)
This works perfectly, however, sometimes the user may not have the CostCenter
so he will enter the ProjectNumber. Thus I have the AfterUpdate event of the
"txtProjectNumber" set to the following.

Me.txtGLCode = DLookup("GLCode", "tblList", "ProjectNumber =" & Me.
txtProjectNumber)

When entering the ProjectNumber I get the syntax error '3075' "syntax error
in number in query expression 'ProjectNumber = 4190740.1570003.00'

All my project numbers come in that format. Is it the format of the data
causing this?
Numbers don't get surrounded by quotes. Text fields do. Dates are
surrounded by #s. So maybe
Me.txtGLCode = DLookup("GLCode", "tblList", _
"ProjectNumber =""" & Me.txtProjectNumber & """)
would work.
Sep 5 '07 #2

P: n/a
The only field that is a number field is the txtCostCenter field with which I
don't have any problem. The txtProjectNumber and txtGLCode fields are text
fields since there are multiple dots and hyfens appearing in each one.

I tried the method you suggested and I still get a syntax error. The error is:

"Run-time error '3075' "
Syntax error in string query expression 'ProjectNumber ="4199700.00'
Salad wrote:
>Hello Access Monsters,
[quoted text clipped - 19 lines]
>All my project numbers come in that format. Is it the format of the data
causing this?

Numbers don't get surrounded by quotes. Text fields do. Dates are
surrounded by #s. So maybe
Me.txtGLCode = DLookup("GLCode", "tblList", _
"ProjectNumber =""" & Me.txtProjectNumber & """)
would work.
--
Message posted via http://www.accessmonster.com

Sep 6 '07 #3

P: n/a
Never Mind. I figured it out. You were right. It had to do with quotation
marks. Thanks allot.

injanib wrote:
>The only field that is a number field is the txtCostCenter field with which I
don't have any problem. The txtProjectNumber and txtGLCode fields are text
fields since there are multiple dots and hyfens appearing in each one.

I tried the method you suggested and I still get a syntax error. The error is:

"Run-time error '3075' "
Syntax error in string query expression 'ProjectNumber ="4199700.00'
>>Hello Access Monsters,
[quoted text clipped - 7 lines]
>> "ProjectNumber =""" & Me.txtProjectNumber & """)
would work.
--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200709/1

Sep 6 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.