F
FlyingDragon via AccessMonster.com
hi all
i have a form with button when i click it execute the code
Private Sub Command12_Click()
On Error GoTo Err_cmdRunQuery_Click
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strSQL As String
Set db = CurrentDb
'*** create the query based on the information on the form
strSQL = " SELECT Cars.CarNum,Cars.CarKindID,format([Enter Your Date] FROM
Cars WHERE "
strSQL = strSQL & "[CarNum] like """ & Me![CarNum] & """"
strSQL = strSQL & Me![cboLogical]
strSQL = strSQL & " [CarKindID] like """ & Me![CarKindID] & """"
'*** delete the previous query
db.QueryDefs.Delete "SerialNum"
Set qdf = db.CreateQueryDef("SerialNum", strSQL)
'*** open the query
DoCmd.OpenReport "serialnum1", acViewPreview
Exit_cmdRunQuery_Click:
Exit Sub
Err_cmdRunQuery_Click:
If Err.Number = 3265 Then '*** if the error is the query is missing
Resume Next '*** then skip the delete line and resume on
the next line
Else
MsgBox Err.Description '*** write out the error and exit the sub
Resume Exit_cmdRunQuery_Click
End If
End Sub
my 2 problem is
1 - I want to force the user to enter date when he prompt for [Enter Your
Date]
2 - I want to show the date in report in format yyyy/m/d
thanks for all
(sorry about my english)
i have a form with button when i click it execute the code
Private Sub Command12_Click()
On Error GoTo Err_cmdRunQuery_Click
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strSQL As String
Set db = CurrentDb
'*** create the query based on the information on the form
strSQL = " SELECT Cars.CarNum,Cars.CarKindID,format([Enter Your Date] FROM
Cars WHERE "
strSQL = strSQL & "[CarNum] like """ & Me![CarNum] & """"
strSQL = strSQL & Me![cboLogical]
strSQL = strSQL & " [CarKindID] like """ & Me![CarKindID] & """"
'*** delete the previous query
db.QueryDefs.Delete "SerialNum"
Set qdf = db.CreateQueryDef("SerialNum", strSQL)
'*** open the query
DoCmd.OpenReport "serialnum1", acViewPreview
Exit_cmdRunQuery_Click:
Exit Sub
Err_cmdRunQuery_Click:
If Err.Number = 3265 Then '*** if the error is the query is missing
Resume Next '*** then skip the delete line and resume on
the next line
Else
MsgBox Err.Description '*** write out the error and exit the sub
Resume Exit_cmdRunQuery_Click
End If
End Sub
my 2 problem is
1 - I want to force the user to enter date when he prompt for [Enter Your
Date]
2 - I want to show the date in report in format yyyy/m/d
thanks for all
(sorry about my english)