Can't Match a table record to a value on a form.

G

Guest

Hi there!

I'm trying to make sure that when person enters something in the approval
field on my form, they are authorised to do so. I'm doing it this way
because Senior managers may change and I want future administrators to be
able to add or delete Senior Managers.

strUser ID is a field on my form and PubUserID is a public variable.

Private Sub strAppMgr_BeforeUpdate(Cancel As Integer)
strUserID = PubUserID

Dim db As DAO.Database
Dim rs As DAO.Recordset

Set db = CurrentDb
Set rs = db.OpenRecordset("select * from tblSnrMgrs where strSnrMgrID="
& Me.strUserID, dbOpenSnapshot)
If rs.RecordCount = 0 Then
MsgBox "Sorry, you aren't entitled to approve projects", vbOKOnly,
"So Sorry"
End If

When I do this, I get a message saying too few parameters, expected 1.

What am I doing wrong? Thanks to everyone who replies!

John
 
M

Marshall Barton

Johnny said:
I'm trying to make sure that when person enters something in the approval
field on my form, they are authorised to do so. I'm doing it this way
because Senior managers may change and I want future administrators to be
able to add or delete Senior Managers.

strUser ID is a field on my form and PubUserID is a public variable.

Private Sub strAppMgr_BeforeUpdate(Cancel As Integer)
strUserID = PubUserID

Dim db As DAO.Database
Dim rs As DAO.Recordset

Set db = CurrentDb
Set rs = db.OpenRecordset("select * from tblSnrMgrs where strSnrMgrID="
& Me.strUserID, dbOpenSnapshot)
If rs.RecordCount = 0 Then
MsgBox "Sorry, you aren't entitled to approve projects", vbOKOnly,
"So Sorry"
End If

When I do this, I get a message saying too few parameters, expected 1.


THat means that you have misspelled a field name or used an
unquoted text string.

Double check the name of the senior manager ID field in the
table.

If that field is a Text type field, then the SQL statement
should be:

. . .("select * from tblSnrMgrs where strSnrMgrID=""" &
Me.strUserID & """", . . .
 

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