Invalid use of the .(dot) or ! operator or parentheses


H

Hugh self taught

Hi there all,

My eyes can't see the issue here so it must be something not obvious to the
eye or I've gone blind for looking.

I get the "There is an Invalid use of the .(dot) or ! operator or
parentheses" message when the following code executes

strSQL = "INSERT INTO Couples (CoupleNumber, MaleID, FemaleID)" & _
"VALUES (""" & [Forms]![frmAddUnlistedCouple].NewCplNumber & """, " &
[Forms]![frmAddUnlistedCouple].txtMale & ", " &
[Forms]![frmAddUnlistedCouple].txtFemale & ")"
db.Execute strSQL, dbFailOnError

CoupleNumber = Text while MaleID & FemaleID are Numeric

The confusing part is I copied & pasted the code from elsewhere in my DB &
just changed the variables so I didn't have to re-think the syntax.

Any ideas what could be the cause? I'm lost for ideas at this stage.
 
Ad

Advertisements

D

Douglas J. Steele

Try using ! instead of .in [Forms]![frmAddUnlistedCouple].NewCplNumber,
[Forms]![frmAddUnlistedCouple].txtMale and
[Forms]![frmAddUnlistedCouple].txtFemale.
 
D

DrGUI

Try putting a SPACE in front of the "V" in "VALUES" like:

" VALUES (""" & [Forms]![frmAddUnlistedCouple].NewCplNumber & """, " &
 
H

Hugh self taught

Hi Douglas & DrGui,

Well this was a misleading message. My form is opened by a calling form in
dialog mode to add a new record. The Value "NewCplNumber" comes from a
textbox on the calling form. At the time this message was appearing, I was
testing the form without the calling form being open. As soon as I closed the
form and opened the calling form adding data to invoke the calling of this
form .... viola!! everything worked correctly as programmed. Strange, since I
would have expected some other message like invalid use of null or such
instead.

End result - problem sorted despite the misleading message.

Douglas J. Steele said:
Try using ! instead of .in [Forms]![frmAddUnlistedCouple].NewCplNumber,
[Forms]![frmAddUnlistedCouple].txtMale and
[Forms]![frmAddUnlistedCouple].txtFemale.

--
Doug Steele, Microsoft Access MVP
http://www.AccessMVP.com/DJSteele
Co-author: Access 2010 Solutions, published by Wiley
(no e-mails, please!)

Hugh self taught said:
Hi there all,

My eyes can't see the issue here so it must be something not obvious to
the
eye or I've gone blind for looking.

I get the "There is an Invalid use of the .(dot) or ! operator or
parentheses" message when the following code executes

strSQL = "INSERT INTO Couples (CoupleNumber, MaleID, FemaleID)" & _
"VALUES (""" & [Forms]![frmAddUnlistedCouple].NewCplNumber & """, " &
[Forms]![frmAddUnlistedCouple].txtMale & ", " &
[Forms]![frmAddUnlistedCouple].txtFemale & ")"
db.Execute strSQL, dbFailOnError

CoupleNumber = Text while MaleID & FemaleID are Numeric

The confusing part is I copied & pasted the code from elsewhere in my DB &
just changed the variables so I didn't have to re-think the syntax.

Any ideas what could be the cause? I'm lost for ideas at this stage.


.
 
Ad

Advertisements

A

AccessVandal via AccessMonster.com

Spot on, DrGUI,

Don't know how he's getting the action query to work though.
Try putting a SPACE in front of the "V" in "VALUES" like:

" VALUES (""" & [Forms]![frmAddUnlistedCouple].NewCplNumber & """, " &
 
Ad

Advertisements


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