tomtom1126
Registered User.
- Local time
- Today, 22:59
- Joined
- Aug 11, 2015
- Messages
- 27
Dear All,
I am the new in VBA.
Below VBA use to filter the Query or Table by using the FORM with the combobox, it's fine until I changed to open (Append Query), the below error message coming up.
( Then action or method is invalid because the form or report isn't bound to a table or query).
Anyone can help, please !
Private Sub cmdUpdateData_Click()
On Error GoTo Errorfound
RecordSource = tblHandlingTemp
Const MESSAGETEXT = "Please Input the Date Range or Select the Vessel Information."
Dim strCriteria As String
If IsNull(Me.txtStartDate) Or IsNull(Me.txtEnddate) Or IsNull(Me.txtVsl) Then
MsgBox MESSAGETEXT, vbExclamation, "Invalid Operation"
Else
strCriteria = BuildCriteria("hkycd", dbText, Me.txtTml) & _
" and hketb >= #" & Format(Me.txtStartDate, "yyyy-mm-dd") & _
"# and hketb < #" & Format(Me.txtEnddate, "yyyy-mm-dd") & "#+1"
strCriteria = strCriteria + " And " + BuildCriteria("hkvsl", dbText, Me.txtVsl)
DoCmd.OpenQuery "qrytest"
DoCmd.ApplyFilter , strCriteria
Errorfound:
MsgBox Err.Description
End If
End Sub
I am the new in VBA.
Below VBA use to filter the Query or Table by using the FORM with the combobox, it's fine until I changed to open (Append Query), the below error message coming up.
( Then action or method is invalid because the form or report isn't bound to a table or query).
Anyone can help, please !
Private Sub cmdUpdateData_Click()
On Error GoTo Errorfound
RecordSource = tblHandlingTemp
Const MESSAGETEXT = "Please Input the Date Range or Select the Vessel Information."
Dim strCriteria As String
If IsNull(Me.txtStartDate) Or IsNull(Me.txtEnddate) Or IsNull(Me.txtVsl) Then
MsgBox MESSAGETEXT, vbExclamation, "Invalid Operation"
Else
strCriteria = BuildCriteria("hkycd", dbText, Me.txtTml) & _
" and hketb >= #" & Format(Me.txtStartDate, "yyyy-mm-dd") & _
"# and hketb < #" & Format(Me.txtEnddate, "yyyy-mm-dd") & "#+1"
strCriteria = strCriteria + " And " + BuildCriteria("hkvsl", dbText, Me.txtVsl)
DoCmd.OpenQuery "qrytest"
DoCmd.ApplyFilter , strCriteria
Errorfound:
MsgBox Err.Description
End If
End Sub