Solved Too few parameters in SQL UPDATE statement (1 Viewer)

Ryan142

Member
Local time
Today, 22:01
Joined
May 12, 2020
Messages
52
Didn't expect to be back so quickly, but here we are...

I'm running an SQL UPDATE Statement to update a users record for information stored on them

This is the code I'm using

Code:
SQLForename = "UPDATE tblUserDetails SET FirstName = " & txtForename & " WHERE LoginID = " & LoginID

LoginID is a public variable defined when the user logs in as a unique id for the user as they enter the system

This is repeated for each text box input then it's run with this:

Code:
CurrentDb.Execute (SQLForename)

This is also copy and pasted for each text box.

Call me blind, but I can't see the issue - although I'm sure it'll be pointed out to me easily.

Any help is as always greatly appreciated.

Thanks, Ryan
 

bob fitz

AWF VIP
Local time
Today, 22:01
Joined
May 23, 2011
Messages
4,726
Try:

SQLForename = "UPDATE tblUserDetails SET FirstName = '" & txtForename & "' WHERE LoginID = " & LoginID
 

CJ_London

Super Moderator
Staff member
Local time
Today, 22:01
Joined
Feb 19, 2013
Messages
16,653
looks like you are missing some single quotes

"UPDATE tblUserDetails SET FirstName = '" & txtForename & "' WHERE LoginID = " & Login

if you debug.print the sql then copy paste to a new query, it often becomes obvious what the problem is
 

Ryan142

Member
Local time
Today, 22:01
Joined
May 12, 2020
Messages
52
Try:

SQLForename = "UPDATE tblUserDetails SET FirstName = '" & txtForename & "' WHERE LoginID = " & LoginID

Fantastic that works, for future reference, why is it just that txtForename part that needs to be put in quotes as well?
Thanks for the reply
 

theDBguy

I’m here to help
Staff member
Local time
Today, 14:01
Joined
Oct 29, 2018
Messages
21,521
Fantastic that works, for future reference, why is it just that txtForename part that needs to be put in quotes as well?
Thanks for the reply
Hi. Just in case it helps, take a look at this article. Cheers!
 

Users who are viewing this thread

Top Bottom