Welsh Punk
New member
- Local time
- Today, 07:20
- Joined
- May 5, 2009
- Messages
- 4
Hi clever ones - havent dipped into access for a while and I have a problem which is probably easy to fix but my head is not straight today lol!
I have four combo boxes that the user has to select (select a date a time a sitting position(window or aisle W or A) and a forwards or backwards facing (F or B). On the onchange event of all the combos I am assigning their seltex to public variables which I want to use in building some sql. I have a button click event then that builds the sql and then needs to assign it to another combo called cboSeats which displays available seating numbers. When I assign the cboSeats rowsource to the sql it does not display anything. I have copied the sql into a query and it brings back rows. Maybe I am not assigning it correctly. Any advice please
Code:::
Private Sub cmdMakeChoice_Click()
On Error GoTo Err_cmdMakeChoice_Click
Dim strFree As String
Dim strSQL As String
strDate = Format(strDate, "dd/mm/yyyy")
strFree = "Free"
strSQL = "SELECT tblSeats.Seat FROM tblJourney INNER JOIN tblSeats ON tblJourney.JourneyID = tblSeats.Journey WHERE tblJourney.Date = '" & strDate & "'"
strSQL = strSQL & " AND tblJourney.Time = '" & strTime & "'"
strSQL = strSQL & " AND tblSeats.Position = '" & strWindowAisle & "'"
strSQL = strSQL & " AND tblSeats.Facing = '" & strFacing & "'"
strSQL = strSQL & " AND tblSeats.[Booking Ref] ='" & strFree & "'"
cboSeats.RowSource = strSQL
cboSeats.Visible = True
'MsgBox (cboSeats.RowSource)
Exit_cmdMakeChoice_Click:
Exit Sub
Err_cmdMakeChoice_Click:
MsgBox Err.Description
Resume Exit_cmdMakeChoice_Click
End Sub
Thanks in advance
I have four combo boxes that the user has to select (select a date a time a sitting position(window or aisle W or A) and a forwards or backwards facing (F or B). On the onchange event of all the combos I am assigning their seltex to public variables which I want to use in building some sql. I have a button click event then that builds the sql and then needs to assign it to another combo called cboSeats which displays available seating numbers. When I assign the cboSeats rowsource to the sql it does not display anything. I have copied the sql into a query and it brings back rows. Maybe I am not assigning it correctly. Any advice please
Code:::
Private Sub cmdMakeChoice_Click()
On Error GoTo Err_cmdMakeChoice_Click
Dim strFree As String
Dim strSQL As String
strDate = Format(strDate, "dd/mm/yyyy")
strFree = "Free"
strSQL = "SELECT tblSeats.Seat FROM tblJourney INNER JOIN tblSeats ON tblJourney.JourneyID = tblSeats.Journey WHERE tblJourney.Date = '" & strDate & "'"
strSQL = strSQL & " AND tblJourney.Time = '" & strTime & "'"
strSQL = strSQL & " AND tblSeats.Position = '" & strWindowAisle & "'"
strSQL = strSQL & " AND tblSeats.Facing = '" & strFacing & "'"
strSQL = strSQL & " AND tblSeats.[Booking Ref] ='" & strFree & "'"
cboSeats.RowSource = strSQL
cboSeats.Visible = True
'MsgBox (cboSeats.RowSource)
Exit_cmdMakeChoice_Click:
Exit Sub
Err_cmdMakeChoice_Click:
MsgBox Err.Description
Resume Exit_cmdMakeChoice_Click
End Sub
Thanks in advance