Howlsta
Vampire Slayer
- Local time
- Today, 18:02
- Joined
- Jul 18, 2001
- Messages
- 180
I need to parameters in the below code the one is passed ok, but i'm trying to give the first parameter StudentIDF using an SQL statement. I assigned the SQL statement to variable StrSQL, but it's not being recognised as a parameter it seems like it's taking it as a string, but if I remove the "" a syntax error occurs. Anyone know what is wrong? The offending code is below.
Rich
Private Sub cmdSelect_Click()
Dim rst As ADODB.Recordset
Dim strSQL As String
strSQL = "SELECT tblStudent.StudentIDF from tblStudent where tblStudent.UBNumber = txtUB"
Set rst = New ADODB.Recordset
With rst
.ActiveConnection = CurrentProject.Connection
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
.Open "Select * from qryPickOption"
.AddNew
!StudentIDF = strSQL
!ModuleIDF = Me.cboOptionalMod
.Update
End With
Me.lboOptions.Requery
End Sub
Rich
Private Sub cmdSelect_Click()
Dim rst As ADODB.Recordset
Dim strSQL As String
strSQL = "SELECT tblStudent.StudentIDF from tblStudent where tblStudent.UBNumber = txtUB"
Set rst = New ADODB.Recordset
With rst
.ActiveConnection = CurrentProject.Connection
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
.Open "Select * from qryPickOption"
.AddNew
!StudentIDF = strSQL
!ModuleIDF = Me.cboOptionalMod
.Update
End With
Me.lboOptions.Requery
End Sub