encore0000
MIS
I am getting an error : User Defined-type not defined on the third like Dim dbNm As Database. I am very new to VB and Access. I am trying to creat a method which searches the database based on the stuff entered in the textboxes and then opens a form with the results.
Private Sub cmdSearch_Click()
'Set the Dimensions of the Module
Dim strSQL As String, strOrder As String, strWhere As String
Dim dbNm As Database ->>>> Error
Dim qryDef As QueryDef
Set dbNm = CurrentDb()
'Constant Select statement for the RowSource
strSQL = "SELECT tblTicketInfo.Machine_Number, tblTicketInfo.user_ID, tblTicketInfo.ticketStatus_ID, tblTicketInfo.location_name " & _
"FROM tblTicketInfo"
strWhere = "WHERE"
strOrder = "ORDER BY tblTicketInfo.Machine_Number;"
'Set the WHERE clause for the Listbox RowSource if information has been entered into a field on the form
If Not IsNull(Me.txtMachine) Then '<--If the textbox txtMachine contains no data THEN do nothing
strWhere = strWhere & " (tblTicketInfo.Machine_Number) Like '*" & Me.txtMachine & "*' AND" '<--otherwise, apply the LIKE statment to the QueryDef
End If
If Not IsNull(Me.txtUser) Then
strWhere = strWhere & " (tblTicketInfo.user_ID) Like '*" & Me.txtUser & "*' AND"
End If
If Not IsNull(Me.txtCity) Then
strWhere = strWhere & " (tblInfo.City) Like '*" & Me.txtCity & "*' AND"
End If
If Not IsNull(Me.txtStatus) Then
strWhere = strWhere & " (tblTicketInfo.ticketStatus_ID) Like '*" & Me.txtStatus & "*' AND"
End If
'Remove the last AND from the SQL statment
strWhere = Mid(strWhere, 1, Len(strWhere) - 5)
'Pass the SQL to the RowSource of the listbox
Me.lstCustInfo.RowSource = strSQL & " " & strWhere & "" & strOrder
End Sub
Private Sub lstCustInfo_DblClick(Cancel As Integer)
'Open frmCustomer based on the ID from lstCustInfo listbox
DoCmd.OpenForm "frmCustomer", , , "[Machine_Number] = " & Me.lstCustInfo, , acDialog
End Sub
Private Sub cmdSearch_Click()
'Set the Dimensions of the Module
Dim strSQL As String, strOrder As String, strWhere As String
Dim dbNm As Database ->>>> Error
Dim qryDef As QueryDef
Set dbNm = CurrentDb()
'Constant Select statement for the RowSource
strSQL = "SELECT tblTicketInfo.Machine_Number, tblTicketInfo.user_ID, tblTicketInfo.ticketStatus_ID, tblTicketInfo.location_name " & _
"FROM tblTicketInfo"
strWhere = "WHERE"
strOrder = "ORDER BY tblTicketInfo.Machine_Number;"
'Set the WHERE clause for the Listbox RowSource if information has been entered into a field on the form
If Not IsNull(Me.txtMachine) Then '<--If the textbox txtMachine contains no data THEN do nothing
strWhere = strWhere & " (tblTicketInfo.Machine_Number) Like '*" & Me.txtMachine & "*' AND" '<--otherwise, apply the LIKE statment to the QueryDef
End If
If Not IsNull(Me.txtUser) Then
strWhere = strWhere & " (tblTicketInfo.user_ID) Like '*" & Me.txtUser & "*' AND"
End If
If Not IsNull(Me.txtCity) Then
strWhere = strWhere & " (tblInfo.City) Like '*" & Me.txtCity & "*' AND"
End If
If Not IsNull(Me.txtStatus) Then
strWhere = strWhere & " (tblTicketInfo.ticketStatus_ID) Like '*" & Me.txtStatus & "*' AND"
End If
'Remove the last AND from the SQL statment
strWhere = Mid(strWhere, 1, Len(strWhere) - 5)
'Pass the SQL to the RowSource of the listbox
Me.lstCustInfo.RowSource = strSQL & " " & strWhere & "" & strOrder
End Sub
Private Sub lstCustInfo_DblClick(Cancel As Integer)
'Open frmCustomer based on the ID from lstCustInfo listbox
DoCmd.OpenForm "frmCustomer", , , "[Machine_Number] = " & Me.lstCustInfo, , acDialog
End Sub