n Form from Switchboard Error

J

JohnV

I am reposting this message as I have not yet resolved the
problem:

I now have specified the form instead of using "Me!". I
still have the same problem.

I have also noticed that when I open the form from the
switchboard that my form no longer has the first record
loaded or the ability to navigate among the records. This
leads me to believe that the problem is on the initial
opening of the form from the switchboard.

Here is my current code:

Private Sub Combo32_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Dim fs As Form

Set fs = Forms!frmOfficeEmployees
Set rs = fs.Recordset.Clone
rs.FindFirst "[Office] = '" & fs![Combo32] & "'"
fs.Bookmark = rs.Bookmark
End Sub

Thanks,
JohnV
-----Original Message-----
I think the switchboard does not know or recognize
the "Me!" - from the switchboard you must call the form
by name - the me reference only owrks when there is only
one possible form to refer to.
-----Original Message-----
I have a form that contains a subform. The form has a
combo box that allows the user to select from and then
synchronizes the subform to filter on that item.

The problem is that when I open the form through the
Switchboard I get an error when I select an item from the
combo box:
"Run-time error '3021':" and "No current record"

I noticed in the code for the combo box which I included
below that it uses a bookmark. This is the point where it
errors. As I stated earlier, when I open the form
directly it works fine.
Private Sub Combo32_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[Office] = '" & Me![Combo32] & "'"
Me.Bookmark = rs.Bookmark
End Sub

Any help would be appreciated.

Regards,
JohnV
 
J

JohnV

Thanks Jim,

You got me pointed in the right direction. This piece of
code was the problem:

' Open a form in Add mode.
Case conCmdOpenFormAdd
DoCmd.OpenForm rs![Argument], , , , acAdd

With this type of form we cannot open in Add Mode.

Regards,
JohnV
-----Original Message-----
John:

If your looking to navigate records from a combobox, you may want to change
your code, try this:

Private Sub Combo32_AfterUpdate() 'First, name this combo box something!

Dim rs As DAO.Recordset
Set rs = me.RecordsetClone

rs.FindFirst "[Office] = " & me.Combo32
me.bookmark = rs.bookmark

End Sub

Another thing you may want to consider is how the switchboard is opening the
form. If there is something in the "WhereClause" part of the DoCmd object,
your recordset is only going to have ONE record, thus negating the
Combo32_AfterUpdate().

DoCmd.OpenForm "frmCrazyFormThatsBroken", acNormal, , strWhereCrit

Actually I'm having sort of a similar problem that you are, now that I think
about it. Anyways, i hope that helps.

Jim Jawn

JohnV said:
I am reposting this message as I have not yet resolved the
problem:

I now have specified the form instead of using "Me!". I
still have the same problem.

I have also noticed that when I open the form from the
switchboard that my form no longer has the first record
loaded or the ability to navigate among the records. This
leads me to believe that the problem is on the initial
opening of the form from the switchboard.

Here is my current code:

Private Sub Combo32_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Dim fs As Form

Set fs = Forms!frmOfficeEmployees
Set rs = fs.Recordset.Clone
rs.FindFirst "[Office] = '" & fs![Combo32] & "'"
fs.Bookmark = rs.Bookmark
End Sub

Thanks,
JohnV
-----Original Message-----
I think the switchboard does not know or recognize
the "Me!" - from the switchboard you must call the form
by name - the me reference only owrks when there is only
one possible form to refer to.
-----Original Message-----
I have a form that contains a subform. The form has a
combo box that allows the user to select from and then
synchronizes the subform to filter on that item.

The problem is that when I open the form through the
Switchboard I get an error when I select an item from
the
combo box:
"Run-time error '3021':" and "No current record"

I noticed in the code for the combo box which I included
below that it uses a bookmark. This is the point where
it
errors. As I stated earlier, when I open the form
directly it works fine.
Private Sub Combo32_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[Office] = '" & Me![Combo32] & "'"
Me.Bookmark = rs.Bookmark
End Sub

Any help would be appreciated.

Regards,
JohnV


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top