Call Button on Another Form Issue

123dstreet

Registered User.
Local time
Today, 10:58
Joined
Apr 14, 2010
Messages
122
I have a form (form1) which will open another form (form2) and apply a filter using a filter button already on form 2. I have applied the following code which works properly for 2 of the 3 forms this needs to be done on:

The below line 'Call Forms.[RMA Data].Command40_Click' works for both BT200 and STB100, but returns an error for BT100 'Object doesn't support this property or method'.

I'm guessing there's a setting on the BT100 form preventing this filter from running, any ideas???

Code:
Private Sub Command99_Click()
On Error GoTo Err_Command99_Click

    Dim stDocName As String
    Dim stLinkCriteria As String
    Dim strRMA As String
    Dim strProduct As String
    Dim strSN As String
    
'set SN variable from Support log record
    If IsNull(Me.wstSN) = False Then strSN = Me.wstSN
    If IsNull(Me.wstSN) = True Then
    MsgBox "Nothing to show for this unit."
    Exit Sub
    End If
    
'determine product
strProduct = Me.Product

If strProduct = "BT100" Then GoTo BT100
If strProduct = "BT200" Then GoTo BT200
If strProduct = "STB100" Then GoTo STB100
Exit Sub

BT100:
    stDocName = "RMA Data"
    DoCmd.OpenForm stDocName
    'set search criteria and run filter command from RMA form
     Forms![RMA Data]![Text38] = strSN
    Call Forms.[RMA Data].Command40_Click
    DoCmd.GoToRecord , , acLast
Exit Sub

BT200:
    stDocName = "RMABT200form"
    DoCmd.OpenForm stDocName
    'set search criteria and run filter command from RMA form
    'Forms!RMABT200form![Text43] = strRMA
    'Call Forms.RMABT200form.Command45_Click
    'If IsNull(strSN) = False Then
    Forms!RMABT200form![Text38] = strSN
    Call Forms.RMABT200form.Command40_Click
    'End If
    DoCmd.GoToRecord , , acLast
Exit Sub

STB100:
    stDocName = "RMASTB100form"
    DoCmd.OpenForm stDocName
    'set search criteria and run filter command from RMA form
      Forms!RMASTB100form![Text38] = strSN
        Call Forms.RMASTB100form.Command40_Click
    DoCmd.GoToRecord , , acLast
Exit Sub
 
did you also make Command40_Click event on form "RMA Data", Public?
 
Yes, I changed the Click events on these forms to Public:
The code for all 3 forms is basically identical. The below code runs fine when run from the RMA Data form.

Code:
Public Sub Command40_Click()
On Error GoTo ExitError
    '-- Find Serial Numbers starting with ---
    Me.Filter = "[Serial Number] Like" & "'" & Me.Text38 & "*" & "'"
    If IsNull([Text38]) = False Then Me.FilterOn = True Else Me.FilterOn = False
    SendKeys "+{Down}"
ExitError:
    Exit Sub
End Sub
 
Thanks Pat,
I'm definitely a hack.

Is it possible to use a Where argument to filter a Continuous form? I would definitely prefer to use this method I just didn't know if it would work.
 
Okay I'll give this a try.
I'm still curious though why the identical Call function is working on 2 other forms no problem but returning an error on this form.
 
Is this Where argument syntax correct?
strWhere = "Forms![RMA Data]![Serial Number] Like" & "'" & Me.wstSN & "*" & "'"
 
I've got it working with Where now, thanks for your help Pat!

Code:
BT100:
    stDocName = "RMA Data"
    strWhere = "[Serial Number]=" & strSN
    DoCmd.OpenForm stDocName, , , strWhere
    DoCmd.GoToRecord , , acLast
Exit Sub

BT200:
    stDocName = "RMABT200form"
    strWhere = "[SN]=" & strSN
    DoCmd.OpenForm stDocName, , , strWhere
    DoCmd.GoToRecord , , acLast
Exit Sub

STB100:
    stDocName = "RMASTB100form"
    strWhere = "[SN]=" & strSN
    DoCmd.OpenForm stDocName, , , strWhere
    DoCmd.GoToRecord , , acLast
Exit Sub
 
Last edited:
Hi Pat,
The gotorecord is because there could be several records displayed but the last one is where I want to land first.

There's only 1 button, 3 IF's, each IF has its own solution - how would you do that less obfuscated? Please share.
 
Hi Pat,
Thanks for the input, I appreciate all the help I can get these days. Always learning something new!
 

Users who are viewing this thread

Back
Top Bottom