SQL Insert into - unable to pass Value parameter (1 Viewer)

IanO

Registered User.
Local time
Today, 11:15
Joined
Jan 2, 2014
Messages
25
MS Access 2010
I am adding a single record to a Table PEFDonationsCong with one of the field names CongID which is numeric.
A button click is supposed to add the record from the Form to the table

Code:
Private Sub AddCong_Click()
Dim strSQL As String
Dim integCongID As Integer
integCongID = Me.ComboCongID
strSQL = "INSERT INTO PEFDonationsCong (CongID) VALUES (integCongID)"
DoCmd.RunSQL strSQL
End Sub

Debugging, I get the correct value integCongID = 256 but strQL still displays:
INSERT INTO PEFDonationsCong (CongID) VALUES (integCongID) and not 256
1. Since it does not recognise the VALUE it requests the parameter value and will correctly append the record
1. If I replace integCongID with the number 256 the sub will continue and add a record with the correct number

I have searched for days and cannot get it to accept a VALUE
I would really appreciate any help here
 
Last edited by a moderator:

Isaac

Lifelong Learner
Local time
Today, 02:15
Joined
Mar 14, 2017
Messages
8,777
Code:
Private Sub AddCong_Click()
Dim strSQL As String
Dim integCongID As Integer
integCongID = Me.ComboCongID
strSQL = "INSERT INTO PEFDonationsCong (CongID) VALUES (" & integCongID & ")"
DoCmd.RunSQL strSQL
End Sub
 

IanO

Registered User.
Local time
Today, 11:15
Joined
Jan 2, 2014
Messages
25
Wow. Thank you and much appreciated
 

Isaac

Lifelong Learner
Local time
Today, 02:15
Joined
Mar 14, 2017
Messages
8,777
Glad it helped you good luck with your project
 

Users who are viewing this thread

Top Bottom