Good Morning,
I have two sub procedures calls form_open event and pass in openargs to the procedure.
The openargs are work_ord_lookup and shipped_dates. They are two fields/columns in the same table bound to the same form. Depending on the openargs passed in I need the form to open and filter by that value.
I believe I’ll need the variable name of the openargs instead of the value so it will know which filter to execute in IF statement, but I’m not sure how I can get it.
This is what I like to do but it is not working. There is no error appeared but the if statements is NOT being executed. I don’t think is syntax but it doesn’t recognize the If Or ElseIf statements.
I am using Access 2000 and SQL server BE.
Your help is greatly appreciated.
Thank you.
Private Sub Form_Open(cancel As Integer)
Dim work_ord_lookup As String
Dim bdt As Date
Dim bdate As String
Dim blankpos As Integer
If Me.OpenArgs = "work_ord_lookup" Then
work_ord_lookup = Me.OpenArgs
DoCmd.ApplyFilter , "work_ord_num = '" & work_ord_lookup & "'"
ElseIf Me.OpenArgs = "shipped_dates" Then
bdate = Me.OpenArgs
blankpos = InStr(1, bdate, " ")
bdt = Left$(bdate, blankpos - 1)
DoCmd.ApplyFilter , "[shipped_date] > '" & bdt & "'" 'and " & '" & edt & "'
End If
End Sub
Private Sub w_o__history_Click()
Dim work_ord_lookup As String
On Error GoTo Err_w_o_history_Click
Dim stDocName As String
stDocName = "shipment_history_list"
work_ord_lookup = Me!shipping_sched_list_subform.Form!work_ord_num.Value '' & " " & Me!shipping_sched_list_subform.Form!work_ord_line_num.Value
DoCmd.OpenForm FormName:=stDocName, OpenArgs:=work_ord_lookup
Exit_w_o_history_Click:
'Set check_wo_history = Nothing
Exit Sub
Err_w_o_history_Click:
MsgBox Err.Description
Resume Exit_w_o_history_Click
End Sub
Private Sub Preview_Click()
Dim bdt As Date
Dim edt As Date
Dim shipped_dates As String
bdt = Me![Beginning Entry Date]
edt = Me![Ending Entry Date]
If IsNull([Beginning Entry Date]) Or IsNull([Ending Entry Date]) Then
MsgBox "You must enter both beginning and ending dates."
DoCmd.GoToControl "Beginning Entry Date"
Else
If [Beginning Entry Date] > [Ending Entry Date] Then
MsgBox "Ending date must be greater than Beginning date."
DoCmd.GoToControl "Beginning Entry Date"
End If
End If
shipped_dates = bdt & " " & edt
'"
DoCmd.OpenForm "shipment_history_list", OpenArgs:=shipped_dates
End Sub
I have two sub procedures calls form_open event and pass in openargs to the procedure.
The openargs are work_ord_lookup and shipped_dates. They are two fields/columns in the same table bound to the same form. Depending on the openargs passed in I need the form to open and filter by that value.
I believe I’ll need the variable name of the openargs instead of the value so it will know which filter to execute in IF statement, but I’m not sure how I can get it.
This is what I like to do but it is not working. There is no error appeared but the if statements is NOT being executed. I don’t think is syntax but it doesn’t recognize the If Or ElseIf statements.
I am using Access 2000 and SQL server BE.
Your help is greatly appreciated.
Thank you.
Private Sub Form_Open(cancel As Integer)
Dim work_ord_lookup As String
Dim bdt As Date
Dim bdate As String
Dim blankpos As Integer
If Me.OpenArgs = "work_ord_lookup" Then
work_ord_lookup = Me.OpenArgs
DoCmd.ApplyFilter , "work_ord_num = '" & work_ord_lookup & "'"
ElseIf Me.OpenArgs = "shipped_dates" Then
bdate = Me.OpenArgs
blankpos = InStr(1, bdate, " ")
bdt = Left$(bdate, blankpos - 1)
DoCmd.ApplyFilter , "[shipped_date] > '" & bdt & "'" 'and " & '" & edt & "'
End If
End Sub
Private Sub w_o__history_Click()
Dim work_ord_lookup As String
On Error GoTo Err_w_o_history_Click
Dim stDocName As String
stDocName = "shipment_history_list"
work_ord_lookup = Me!shipping_sched_list_subform.Form!work_ord_num.Value '' & " " & Me!shipping_sched_list_subform.Form!work_ord_line_num.Value
DoCmd.OpenForm FormName:=stDocName, OpenArgs:=work_ord_lookup
Exit_w_o_history_Click:
'Set check_wo_history = Nothing
Exit Sub
Err_w_o_history_Click:
MsgBox Err.Description
Resume Exit_w_o_history_Click
End Sub
Private Sub Preview_Click()
Dim bdt As Date
Dim edt As Date
Dim shipped_dates As String
bdt = Me![Beginning Entry Date]
edt = Me![Ending Entry Date]
If IsNull([Beginning Entry Date]) Or IsNull([Ending Entry Date]) Then
MsgBox "You must enter both beginning and ending dates."
DoCmd.GoToControl "Beginning Entry Date"
Else
If [Beginning Entry Date] > [Ending Entry Date] Then
MsgBox "Ending date must be greater than Beginning date."
DoCmd.GoToControl "Beginning Entry Date"
End If
End If
shipped_dates = bdt & " " & edt
'"
DoCmd.OpenForm "shipment_history_list", OpenArgs:=shipped_dates
End Sub