Can someone explain to me the rules I need to follow when using strings in an SQL statement in VB. I've written the following code which works perfectly when it uses an int or long but not for a string... why is that?
Private Sub Command3_Click()
Dim strSector As String
Dim strSQL As String
If IsNull(Me.Combo9) Then
MsgBox "Please select a sector", vbOKOnly
Else
strSector = Forms!FrmSelectSector!Combo9.Value
strSQL = "Sector = " & strSector & ""
DoCmd.OpenForm "frmOrgsBySector", , , strSQL
DoCmd.Close acForm, "FrmSelectSector"
DoCmd.Close acForm, "FrmMain"
DoCmd.Maximize
End If
End Sub
Private Sub Command3_Click()
Dim strSector As String
Dim strSQL As String
If IsNull(Me.Combo9) Then
MsgBox "Please select a sector", vbOKOnly
Else
strSector = Forms!FrmSelectSector!Combo9.Value
strSQL = "Sector = " & strSector & ""
DoCmd.OpenForm "frmOrgsBySector", , , strSQL
DoCmd.Close acForm, "FrmSelectSector"
DoCmd.Close acForm, "FrmMain"
DoCmd.Maximize
End If
End Sub