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

  • Thread starter Thread starter Hugh self taught
  • Start date Start date
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.
 
Try using ! instead of .in [Forms]![frmAddUnlistedCouple].NewCplNumber,
[Forms]![frmAddUnlistedCouple].txtMale and
[Forms]![frmAddUnlistedCouple].txtFemale.
 
Try putting a SPACE in front of the "V" in "VALUES" like:

" VALUES (""" & [Forms]![frmAddUnlistedCouple].NewCplNumber & """, " &
 
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.


.
 
Back
Top