Select Statement

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,
Can anyone tell me what's wrong with the folloing select statement? I keep
getting an error that I'm using an invalid character. I'm running the
statement from Form/Current.

Set rs = CurrentDb.OpenRecordset( _
"SELECT Floor, from tblUsers WHERE [tblUsers.LoginID] = " &
Form_frmComputers.LoginID)

I'm afraid I just can't see what's wrong. Thanks very much for your help.
 
Joanne said:
Can anyone tell me what's wrong with the folloing select statement? I keep
getting an error that I'm using an invalid character. I'm running the
statement from Form/Current.

Set rs = CurrentDb.OpenRecordset( _
"SELECT Floor, from tblUsers WHERE [tblUsers.LoginID] = " &
Form_frmComputers.LoginID)


.... "SELECT Floor From tblUsers WHERE tblUsers.LoginID = "
& Me.LoginID)

You form reference was not appropriate. Me refers to the
form reference for the form containing your code. If
frmComputers is a different form, then replace Me with
Forms!frmComputers.

If LoginID is a text **field** in tblUsers, then use:

.... "SELECT Floor From tblUsers WHERE tblUsers.LoginID =
""" & Me.LoginID & """")
 
Hello,
Thank you so much for your help. I now have the following statement and
it's saying there are too few parameters. I feel very foolish for being
stuck on this statement. I am in frmComputers when I run it but it looks
like I have enough parameters, no?

Set rs = CurrentDb.OpenRecordset("SELECT Floor From tblUsers WHERE
tblUsers.LoginID = " & Form_frmComputers.LoginID)

Marshall Barton said:
Joanne said:
Can anyone tell me what's wrong with the folloing select statement? I keep
getting an error that I'm using an invalid character. I'm running the
statement from Form/Current.

Set rs = CurrentDb.OpenRecordset( _
"SELECT Floor, from tblUsers WHERE [tblUsers.LoginID] = " &
Form_frmComputers.LoginID)


.... "SELECT Floor From tblUsers WHERE tblUsers.LoginID = "
& Me.LoginID)

You form reference was not appropriate. Me refers to the
form reference for the form containing your code. If
frmComputers is a different form, then replace Me with
Forms!frmComputers.

If LoginID is a text **field** in tblUsers, then use:

.... "SELECT Floor From tblUsers WHERE tblUsers.LoginID =
""" & Me.LoginID & """")
 
You should not have any parameters. The message implies
that either Floor or LoginID is not a field in the table, or
LoginID is a Text field and you need the quotes I pointed
out before.
--
Marsh
MVP [MS Access]

Thank you so much for your help. I now have the following statement and
it's saying there are too few parameters. I feel very foolish for being
stuck on this statement. I am in frmComputers when I run it but it looks
like I have enough parameters, no?

Set rs = CurrentDb.OpenRecordset("SELECT Floor From tblUsers WHERE
tblUsers.LoginID = " & Form_frmComputers.LoginID)

Marshall Barton said:
Joanne said:
Can anyone tell me what's wrong with the folloing select statement? I keep
getting an error that I'm using an invalid character. I'm running the
statement from Form/Current.

Set rs = CurrentDb.OpenRecordset( _
"SELECT Floor, from tblUsers WHERE [tblUsers.LoginID] = " &
Form_frmComputers.LoginID)


.... "SELECT Floor From tblUsers WHERE tblUsers.LoginID = "
& Me.LoginID)

You form reference was not appropriate. Me refers to the
form reference for the form containing your code. If
frmComputers is a different form, then replace Me with
Forms!frmComputers.

If LoginID is a text **field** in tblUsers, then use:

.... "SELECT Floor From tblUsers WHERE tblUsers.LoginID =
""" & Me.LoginID & """")
 
Thank you very much. It's working fine now.

Marshall Barton said:
You should not have any parameters. The message implies
that either Floor or LoginID is not a field in the table, or
LoginID is a Text field and you need the quotes I pointed
out before.
--
Marsh
MVP [MS Access]

Thank you so much for your help. I now have the following statement and
it's saying there are too few parameters. I feel very foolish for being
stuck on this statement. I am in frmComputers when I run it but it looks
like I have enough parameters, no?

Set rs = CurrentDb.OpenRecordset("SELECT Floor From tblUsers WHERE
tblUsers.LoginID = " & Form_frmComputers.LoginID)

Marshall Barton said:
Joanne wrote:
Can anyone tell me what's wrong with the folloing select statement? I keep
getting an error that I'm using an invalid character. I'm running the
statement from Form/Current.

Set rs = CurrentDb.OpenRecordset( _
"SELECT Floor, from tblUsers WHERE [tblUsers.LoginID] = " &
Form_frmComputers.LoginID)


.... "SELECT Floor From tblUsers WHERE tblUsers.LoginID = "
& Me.LoginID)

You form reference was not appropriate. Me refers to the
form reference for the form containing your code. If
frmComputers is a different form, then replace Me with
Forms!frmComputers.

If LoginID is a text **field** in tblUsers, then use:

.... "SELECT Floor From tblUsers WHERE tblUsers.LoginID =
""" & Me.LoginID & """")
 
Back
Top