What is wrong with this code ?

W

Wayne-I-M

Hi

I have been looking at a post from yesterday (and as I have some time at the
moment) I have been trying to work out the best way to answer.

The post (I forget who it was from - sorry if it was you) basically wanted
to click a record on a subform (I imagin it was continous unbound) and use
this OnClick to GoTo a record on the main form.

This code work (sort of)

On the subform

Private Sub Button_Click()
Forms!MainFormName!SomeTextBox =
Forms!MainFOrmName!SubFormName.Form!AnotherTextBox
Forms!MainFormName!SomeTextBox.SetFocus
End Sub

On the Main Form

Private Sub SomeTextBox_GotFocus()
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[ID] = " & Str(Nz(Me![AnotherTextBoxOnSubForm], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub



This "will" change the record on the main form in line with the selection on
the sub form "but" you will get an error message as well (very strange)

RunTime error 2110
Can't set the focus to SomeTextBox

As I said it does work - except for the messge box
I have tried
DoCmd.SetWarnings False - all over the place :)
But no luck.

I would like to answer the post, and it's bugging me now :) so any tips
would be great.
 

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