SQL statement VBA

cedtech23

Registered User.
Local time
Today, 15:23
Joined
Jan 28, 2006
Messages
25
the SQL statement to


Code:
Dim strSQL As String


strSQL = "INSERT INTO tblBloodworkResults (PatientID,HepBAntibodySur,HepBAntigenSur,HepBCoreAntibody,HepCAntibody," _
& "TSH,HemaWithDiff,HIVAntibody,RPRSyphSero,HemoElectro,VaricAntibodyTit,MMRTiter)" _
& " VALUES (" _
& Forms!frmPatientDemographics!PatientID & "," & Me!cboHepBAntibodySur & "," _
& Me!cboHepBAntigenSur & "," & Me!cboHepBCoreAntibody & "," & Me!cboHepCAntibody & "," _
& Me!cboTSH & "," & Me!cboHemaWithDiff & "," & Me!cboHIVAntibody & "," _
& Me!cboRPRSyphSero & "," & Me!cboHemoElectro & "," _
& Me!cboVaricAntibodyTit & "," & Me!cboMMRTiter & ");"

Debug.Print strSQL

CurrentProject.Connection.Execute strSQL

and know I get this message

No Value given for one or more required parameters

you will notice that place the line below in the code

Debug.Print strSQL

when I look at the immediate window I get

Code:
INSERT INTO tblBloodworkResults (PatientID,HepBAntibodySur,HepBAntigenSur,HepBCoreAntibody,HepCAntibody,TSH,HemaWithDiff,HIVAntibody,RPRSyphSero,HemoElectro,VaricAntibodyTit,MMRTiter) VALUES (9,Negative,Negative,Negative,Negative,Negative,Negative,Negative,Negative,Negative,Negative,Negative);

when I look in the table tblBloodworkResults

I see

Code:
0 Negative Negative Negative Negative Negative Negative    Negative Negative Negative Negative Negative

some how the PatientID is not going into the tblBloodworkResults from the SQL statement. Any Ideas??

Funny thing if I type in number like 1,2,3,4, etc.. it works fine

I am wondering since it's string value begin passed is their a special simple that needs to surround the controls in my SQL statements?
example if it was dates I would have to have # #
 
Try surrounding the commas with a single quote instead of a double quote.
 
Close, but your'e going to need those double quotes to send the data as a string.

What you want to do is put single quotes on the each side of the comma, but inside the double quotes.

Code:
...
& " VALUES ([color=red]'[/color]" _
& Forms!frmPatientDemographics!PatientID & "[color=red]'[/color],[color=red]'[/color]" & Me!cboHepBAntibodySur & "[color=red]'[/color],[color=red]'[/color]" _
...

In other words, enclose your text values in single quoted string, number values do not need the single quotes.
 

Users who are viewing this thread

Back
Top Bottom