Error 3131

  • Thread starter Thread starter nomadk
  • Start date Start date
N

nomadk

OK, I'm feeling really dumb today.

<snip>
Set dbs = CurrentDb
StrSQL = "SELECT * FROM (qryAppendOUContact)" &_
"WHERE tblContacts.ContactAutoID = " &_
[Forms]![frmHome]![frmContactsAdd].[Form]![ContactAutoID]
Set rst = dbs.OpenRecordset(StrSQL)

And I get Error 3131.

Help!
 
Well, you don't have tblContacts in the FROM clause. You are missing a
space before the word "WHERE" and if ContactAutoID is not numeric you
are missing quote marks. Plus your line continuations should read
& <space> <> underscore
You are missing the space between the ampersand and the underscore.


StrSQL = "SELECT * FROM (qryAppendOUContact)" & _
" WHERE tblContacts.ContactAutoID = """ & _
[Forms]![frmHome]![frmContactsAdd].[Form]![ContactAutoID] & """"

I would add a
Debug.Print StrSQL
and check the results of the string to see if it is correct.

'====================================================
John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
'====================================================
 
Hi John,

The spaces weren't the issue (Can pasting into a browser window strip spaces
from code?)
The quotes weren't the issue (ContactAutoID is numeric and the closing two
sets of quotes were missing from my post due to my sloppy copy and paste).
The issue was I failed to inlcude tblContacts.ContactAutoID in
qryAppendOUContact.
I'm even dumber than I thought.

Thanks very much for taking the time to post. It forced me to look at the
obvious, which I should have done before I wasted your time.

Thanks again.

John Spencer said:
Well, you don't have tblContacts in the FROM clause. You are missing a
space before the word "WHERE" and if ContactAutoID is not numeric you
are missing quote marks. Plus your line continuations should read
& <space> <> underscore
You are missing the space between the ampersand and the underscore.


StrSQL = "SELECT * FROM (qryAppendOUContact)" & _
" WHERE tblContacts.ContactAutoID = """ & _
[Forms]![frmHome]![frmContactsAdd].[Form]![ContactAutoID] & """"

I would add a
Debug.Print StrSQL
and check the results of the string to see if it is correct.

'====================================================
John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
'====================================================

OK, I'm feeling really dumb today.

<snip>
Set dbs = CurrentDb
StrSQL = "SELECT * FROM (qryAppendOUContact)" &_
"WHERE tblContacts.ContactAutoID = " &_
[Forms]![frmHome]![frmContactsAdd].[Form]![ContactAutoID]
Set rst = dbs.OpenRecordset(StrSQL)

And I get Error 3131.

Help!
 
Back
Top