N
Nadine
Ok so I have a problem! I am creating a simple (or suppose to be
simple) Access application. On one of my pages users can select search
criteria from multiple drop downs to get their results. My problem is
displaying the results I have the qurey worked out and am now stuck!
Any help would be appreciated. Here is the code I have so far.
Private Sub Form_Load()
Dim strSQL As String
'Create a connection to the current Database
Dim cnHospList As ADODB.Connection
Set cnHospList = CurrentProject.Connection
strSQL = "Select * From [tblHospitalNames] "
If Forms!ViewHospBy![cmbProvider] <> " " Then
strSQL = strSQL & "Where [cihi_id] = " &
Forms!ViewHospBy![cmbProvider] & ""
End If
If Forms!ViewHospBy![cmbHAName] <> " " Then
strSQL = strSQL & " AND [ha_id] = " & Forms!ViewHospBy![cmbHAName]
& ""
End If
If Forms!ViewHospBy![cmbHSDAName] <> " " Then
strSQL = strSQL & " AND [hsda_id] = " &
Forms!ViewHospBy![cmbHSDAName] & ""
End If
If Forms!ViewHospBy![cmbLHAName] <> " " Then
strSQL = strSQL & " AND [lha_id] = " &
Forms!ViewHospBy![cmbLHAName] & ""
End If
strSQL = strSQL & " Order By [hosp_id]"
cnHospList.BeginTrans
cnHospList.Execute (strSQL)
cnHospList.CommitTrans
End Sub
simple) Access application. On one of my pages users can select search
criteria from multiple drop downs to get their results. My problem is
displaying the results I have the qurey worked out and am now stuck!
Any help would be appreciated. Here is the code I have so far.
Private Sub Form_Load()
Dim strSQL As String
'Create a connection to the current Database
Dim cnHospList As ADODB.Connection
Set cnHospList = CurrentProject.Connection
strSQL = "Select * From [tblHospitalNames] "
If Forms!ViewHospBy![cmbProvider] <> " " Then
strSQL = strSQL & "Where [cihi_id] = " &
Forms!ViewHospBy![cmbProvider] & ""
End If
If Forms!ViewHospBy![cmbHAName] <> " " Then
strSQL = strSQL & " AND [ha_id] = " & Forms!ViewHospBy![cmbHAName]
& ""
End If
If Forms!ViewHospBy![cmbHSDAName] <> " " Then
strSQL = strSQL & " AND [hsda_id] = " &
Forms!ViewHospBy![cmbHSDAName] & ""
End If
If Forms!ViewHospBy![cmbLHAName] <> " " Then
strSQL = strSQL & " AND [lha_id] = " &
Forms!ViewHospBy![cmbLHAName] & ""
End If
strSQL = strSQL & " Order By [hosp_id]"
cnHospList.BeginTrans
cnHospList.Execute (strSQL)
cnHospList.CommitTrans
End Sub