jason12776
Technical User
I am trying to post the results of a search in both some text boxes as well as a datagrid...
Private Sub cmdLookUp_Click()
Dim Lsql As String, Dsql As String, Msql As String, conn As String
Dim rs As New ADODB.Recordset
Dim dpath As String
dpath = "C:\program files\DVD\dvd.mdb"
conn = "provider=microsoft.jet.oledb.4.0;data source = " & dpath
Lsql = "SELECT * from movie where LentOut <> 'N/A'"
Dsql = "SELECT * from movie where director like '" & txtSearch.Text & "'"
Msql = "SELECT * from movie where movie like '" & txtSearch.Text & "'"
If optLentOut Then
Set rs = New ADODB.Recordset
rs.Open Lsql, conn
With rs
Do Until .EOF
If .Fields("lentout"
<> "N/A" Then
txtMovie.Text = .Fields("movie"
txtDirector.Text = .Fields("director"
txtCatagory.Text = .Fields("category"
txtRating.Text = .Fields("rating"
txtDate.Text = .Fields("date"
txtID.Text = .Fields("ID"
txtTime.Text = .Fields("time"
txtLentOut.Text = .Fields("lentout"
End If
Loop
End With
rs.Close
ElseIf optDirector Then
Set rs = New ADODB.Recordset
rs.Open Dsql, conn
With rs
Do Until .EOF
txtMovie.Text = .Fields("movie"
txtDirector.Text = .Fields("director"
txtCatagory.Text = .Fields("category"
txtRating.Text = .Fields("rating"
txtDate.Text = .Fields("date"
txtID.Text = .Fields("ID"
txtTime.Text = .Fields("time"
txtLentOut.Text = .Fields("lentout"
Loop
End With
rs.Close
ElseIf optMovie Then
Set rs = New ADODB.Recordset
rs.Open Msql, conn
With rs
Do Until .EOF
txtMovie.Text = .Fields("movie"
txtDirector.Text = .Fields("director"
txtCatagory.Text = .Fields("category"
txtRating.Text = .Fields("rating"
txtDate.Text = .Fields("date"
txtID.Text = .Fields("ID"
txtTime.Text = .Fields("time"
txtLentOut.Text = .Fields("lentout"
Loop
End With
rs.Close
Else
Call MsgBox("You must choose an option.", vbCritical, "Error"
End If
end sub
Does all this make sense? Any suggestions will be appreciated.
Cheers.
Private Sub cmdLookUp_Click()
Dim Lsql As String, Dsql As String, Msql As String, conn As String
Dim rs As New ADODB.Recordset
Dim dpath As String
dpath = "C:\program files\DVD\dvd.mdb"
conn = "provider=microsoft.jet.oledb.4.0;data source = " & dpath
Lsql = "SELECT * from movie where LentOut <> 'N/A'"
Dsql = "SELECT * from movie where director like '" & txtSearch.Text & "'"
Msql = "SELECT * from movie where movie like '" & txtSearch.Text & "'"
If optLentOut Then
Set rs = New ADODB.Recordset
rs.Open Lsql, conn
With rs
Do Until .EOF
If .Fields("lentout"
txtMovie.Text = .Fields("movie"
txtDirector.Text = .Fields("director"
txtCatagory.Text = .Fields("category"
txtRating.Text = .Fields("rating"
txtDate.Text = .Fields("date"
txtID.Text = .Fields("ID"
txtTime.Text = .Fields("time"
txtLentOut.Text = .Fields("lentout"
End If
Loop
End With
rs.Close
ElseIf optDirector Then
Set rs = New ADODB.Recordset
rs.Open Dsql, conn
With rs
Do Until .EOF
txtMovie.Text = .Fields("movie"
txtDirector.Text = .Fields("director"
txtCatagory.Text = .Fields("category"
txtRating.Text = .Fields("rating"
txtDate.Text = .Fields("date"
txtID.Text = .Fields("ID"
txtTime.Text = .Fields("time"
txtLentOut.Text = .Fields("lentout"
Loop
End With
rs.Close
ElseIf optMovie Then
Set rs = New ADODB.Recordset
rs.Open Msql, conn
With rs
Do Until .EOF
txtMovie.Text = .Fields("movie"
txtDirector.Text = .Fields("director"
txtCatagory.Text = .Fields("category"
txtRating.Text = .Fields("rating"
txtDate.Text = .Fields("date"
txtID.Text = .Fields("ID"
txtTime.Text = .Fields("time"
txtLentOut.Text = .Fields("lentout"
Loop
End With
rs.Close
Else
Call MsgBox("You must choose an option.", vbCritical, "Error"
End If
end sub
Does all this make sense? Any suggestions will be appreciated.
Cheers.