USING VB6 AND ACCESS 2002 (Sorry Old Stuff)
I am trying to pass 3 variables into an SQL query. I get error: "No value give for one or more required parameters."
There seems to be a problem with the SQL syntax although it compiles perfectly. The SQL statement executes with this:
strSQL = "SELECT * FROM SCHEDULE Where WEEK =" & intWeek & " AND YEAR =" & intYear
But when adding the third variable with AND I get the error message as stated :
strSQL = "SELECT * FROM SCHEDULE Where WEEK =" & intWeek & " AND YEAR =" & intYear & " AND SEASON =" & strSeason
The variable name SEASON matches the correct field name.
Here is the VB code:
Private Sub cmdSubmit_Click()
Dim intYear As Integer
Dim intWeek As Integer
Dim strSeason As String
Dim strSQL As String
If optRegSeason.Value = True Then
strSeason = "R"
Else
strSeason = "P"
End If
intYear = Combo1.Text
intWeek = Combo2.Text
Dim db As Database, rs As Recordset
Set db = OpenDatabase("C:\Documents and Settings\G'Day Mate\My Documents\WASUP.mdb")
Set rs = db.OpenRecordset("SCHEDULE", dbOpenDynaset)
On Error Resume Next
strSQL = "SELECT * FROM SCHEDULE Where WEEK =" & intWeek & " AND YEAR =" & intYear & " AND SEASON =" & strSeason
Adodc1.RecordSource = strSQL
Adodc1.Refresh
Any help would be appreciated.
Gary
I am trying to pass 3 variables into an SQL query. I get error: "No value give for one or more required parameters."
There seems to be a problem with the SQL syntax although it compiles perfectly. The SQL statement executes with this:
strSQL = "SELECT * FROM SCHEDULE Where WEEK =" & intWeek & " AND YEAR =" & intYear
But when adding the third variable with AND I get the error message as stated :
strSQL = "SELECT * FROM SCHEDULE Where WEEK =" & intWeek & " AND YEAR =" & intYear & " AND SEASON =" & strSeason
The variable name SEASON matches the correct field name.
Here is the VB code:
Private Sub cmdSubmit_Click()
Dim intYear As Integer
Dim intWeek As Integer
Dim strSeason As String
Dim strSQL As String
If optRegSeason.Value = True Then
strSeason = "R"
Else
strSeason = "P"
End If
intYear = Combo1.Text
intWeek = Combo2.Text
Dim db As Database, rs As Recordset
Set db = OpenDatabase("C:\Documents and Settings\G'Day Mate\My Documents\WASUP.mdb")
Set rs = db.OpenRecordset("SCHEDULE", dbOpenDynaset)
On Error Resume Next
strSQL = "SELECT * FROM SCHEDULE Where WEEK =" & intWeek & " AND YEAR =" & intYear & " AND SEASON =" & strSeason
Adodc1.RecordSource = strSQL
Adodc1.Refresh
Any help would be appreciated.
Gary