SQL in code

Howlsta

Vampire Slayer
Local time
Today, 08:00
Joined
Jul 18, 2001
Messages
180
What's wrong with the sql in my code below? It's something to do with setting the criteria to PG I think. I tried putting the PG bit in "" but that didn't work either. Anyone know why it's not working? It comes up with an input box with text PG above the text box at the moment. I want it to just put PG in cboYear.

Private Sub cboCourse_AfterUpdate()
If Me.CboCourse.Column(1) = "MSc Computing" Or Me.CboCourse.Column(1) _
= "MSc Software Engineering" Then
Me.cboYear.RowSource = "SELECT DISTINCT tblYears.YearIDF, tblYears.NumberYr " _
& "FROM tblYears WHERE (((tblYears.NumberYr) = PG));"
End If

End Sub

[This message has been edited by Howlsta (edited 09-01-2001).]
 
"SELECT DISTINCT tblYears.YearIDF, tblYears.NumberYr " _
& "FROM tblYears WHERE (((tblYears.NumberYr) = "" & "PG" &""));"

I think that may do it. by putting two quotes each side of the PG you're ensuring the quotes form part of the executable SQL.

Note: You may only need single quotes('") in place of the "" so it may look like

"SELECT DISTINCT tblYears.YearIDF, tblYears.NumberYr " _
& "FROM tblYears WHERE (((tblYears.NumberYr) = '" & "PG" &"'));"

Ian



[This message has been edited by Fornatian (edited 09-01-2001).]
 
Yeah i've got it now, found it in help, I couldn't find it earlier. I had to do the syntax like this 'PG'
Thanks anyway

Rich

[This message has been edited by Howlsta (edited 09-01-2001).]
 

Users who are viewing this thread

Back
Top Bottom