How to open a Pop Up form that shows only the current record?

StagIraq
StagIraq used Ask the Experts™
on
I have been researching how to get my Pop up form to open showing the current record from the main form I called it from.  I found the question, “Using a Pop Up Form for data entry (07/28/03 01:31 PM, ID: 20692792)” to be helpful at first, but it would not run in my db?!?

My main form has the checkbox on it that triggers the pop up form (purpose of pop up is to allow the editing of several fields of data to clarify the reason for non-availability).  I have the following code in the “after update” event for my checkbox control (called [SimPeriodAvailable]):

Private Sub SimPeriodAvailable_AfterUpdate()
   
    If Me.SimPeriodAvailable = 0 Then
       Me.SimDate = Form_SimBuild.TxtSimBuilderDate
    End If
   
    Me.Requery
   
    If Me.SimPeriodAvailable = 0 Then

        DoCmd.OpenForm "simnotavailpopup", , , simulatorlog.simid = Me.txtSimulatorLog_SimID
                   
    End If
End Sub

The pop up form “simnotavailpopup” pulls a select query from the table_SimulatorLog.

I want the pop up to open to the record where the SimID (primary key in SimulatorLog table) is the same as the SimID on the main form (held in textbox “txtSimulatorLog_SimID”).

When run, the DoCmd.OpenForm code above always gives me a “Run Time Error 424…Object Required”
I thought this might be from the main form record being a new record created by the checkbox update, so I added the “Me.Requery” to ensure the pop-up command would find the record in the table.  Still get the “Run Time Error.”

I have tried to change the code to have it look for SimID in multiple different ways, but it always give me the “Object Required” warning.

Please help.

StagIraq
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
Try

Private Sub SimPeriodAvailable_AfterUpdate()

Dim i as integer
i=Me.SimID
 
    If Me.SimPeriodAvailable = 0 Then
       Me.SimDate = Form_SimBuild.TxtSimBuilderDate
    End If
   
    Me.Requery
   
    If Me.SimPeriodAvailable = 0 Then

        DoCmd.OpenForm "simnotavailpopup", , , "simid =" & intID
                 
    End If
End Sub

Author

Commented:
sb9,

I got it to work after I changed the value of "i" and had the form open referencing "i"

Dim i As Integer
i = Me.txtSimulatorLog_SimID
 
    If Me.SimPeriodAvailable = 0 Then
       Me.SimDate = Form_SimBuild.TxtSimBuilderDate
    End If
   
    Me.Requery
   
    If Me.SimPeriodAvailable = 0 Then

        DoCmd.OpenForm "simnotavailpopup", , , "simid =" & i

Thanks!

StagIraq

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial