A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Update Query



 
 
Thread Tools Display Modes
  #1  
Old May 26th, 2004, 09:01 PM
James Stephens
external usenet poster
 
Posts: n/a
Default Update Query

I have used this similar construction to do update from text boxes to a table but this one doesn't seem to work right and I am not sure what exactly is wrong.

CurrentDb.Execute "UPDATE DISTINCTROW Screeners SET Screeners.LoginID = """ & Me![Text37] & """ AND Screeners.[First Name] = """ & Me![Text35] & """ And Screeners.[Last Name] = """ & Me![Text31] & """ And Screeners.[SSN] = """ & Me![Text46] & """ And Screeners.[Position] = """ & Me![Text44] & """ And Screeners.[Gender] = """ & Me![Text42] & """ Where ((Screeners.LoginID = """ & Me![Text52] & """));"

What is basically is supposed to do is take the values in 6 text boxes and assign them to the values from the record in six seperate fields (LoginID, First Name, Last Name, SSN, Position, Gender), and it does this where the value of "LoginID" is equal to the value of a 7th text box. When I run the above code I get "Data Type Mismatch In Criteria Expression". Waht Exactly do I have wrong here, am an not sure what I need to change ?

Any help would be appreciated


  #2  
Old May 26th, 2004, 09:47 PM
Gerald Stanley
external usenet poster
 
Posts: n/a
Default Update Query

You cannot use AND in the SET statement
The correct syntax for updating multiple columns is
SET column1 = 'value1', column2 = value2 (value1 is a text,
value2 is a number)

Hope This Helps
Gerald Stanley MCSD
-----Original Message-----
I have used this similar construction to do update from

text boxes to a table but this one doesn't seem to work
right and I am not sure what exactly is wrong.

CurrentDb.Execute "UPDATE DISTINCTROW

Screeners SET Screeners.LoginID = """ & Me![Text37] & """
AND Screeners.[First Name] = """ & Me![Text35] & """ And
Screeners.[Last Name] = """ & Me![Text31] & """ And
Screeners.[SSN] = """ & Me![Text46] & """ And
Screeners.[Position] = """ & Me![Text44] & """ And
Screeners.[Gender] = """ & Me![Text42] & """ Where
((Screeners.LoginID = """ & Me![Text52] & """));"

What is basically is supposed to do is take the values in

6 text boxes and assign them to the values from the record
in six seperate fields (LoginID, First Name, Last Name,
SSN, Position, Gender), and it does this where the value of
"LoginID" is equal to the value of a 7th text box. When I
run the above code I get "Data Type Mismatch In Criteria
Expression". Waht Exactly do I have wrong here, am an not
sure what I need to change ?

Any help would be appreciated


.

  #3  
Old May 26th, 2004, 10:41 PM
James Stephens
external usenet poster
 
Posts: n/a
Default Update Query

Thanks for the info, that worked great.

----- Gerald Stanley wrote: -----

You cannot use AND in the SET statement
The correct syntax for updating multiple columns is
SET column1 = 'value1', column2 = value2 (value1 is a text,
value2 is a number)

Hope This Helps
Gerald Stanley MCSD
-----Original Message-----
I have used this similar construction to do update from

text boxes to a table but this one doesn't seem to work
right and I am not sure what exactly is wrong.
CurrentDb.Execute "UPDATE DISTINCTROW

Screeners SET Screeners.LoginID = """ & Me![Text37] & """
AND Screeners.[First Name] = """ & Me![Text35] & """ And
Screeners.[Last Name] = """ & Me![Text31] & """ And
Screeners.[SSN] = """ & Me![Text46] & """ And
Screeners.[Position] = """ & Me![Text44] & """ And
Screeners.[Gender] = """ & Me![Text42] & """ Where
((Screeners.LoginID = """ & Me![Text52] & """));"
What is basically is supposed to do is take the values in

6 text boxes and assign them to the values from the record
in six seperate fields (LoginID, First Name, Last Name,
SSN, Position, Gender), and it does this where the value of
"LoginID" is equal to the value of a 7th text box. When I
run the above code I get "Data Type Mismatch In Criteria
Expression". Waht Exactly do I have wrong here, am an not
sure what I need to change ?
Any help would be appreciated
.


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:39 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.