How Can I Focus a Control in a sub form?

G

Guest

Hi ,

I have form wich contains a sub form.The sub form has a field(listbox).
IN the main form there is a button that open another form (ccc) which add
new record in a file (listbox), when i close the form ccc (after adding) and
then i click the field(listbox) in the subform doesn't contain the new value.
 
G

Guest

I tried the following :
(TEST1 = MAIN FORM, TEST2 = SUBFORM)

Forms!TEST1!TEST2.Controls("field").Requery
Form_TEST1!TEST2.Form!field.Requery

me.field.requery

but it doen't work
 
G

Guest

Kimon,

On your form that has the listbox you mention in the following statement
when i close the form ccc (after adding) and then i click the
field(listbox)<, in that form's edit mode, left click on the listbox and
choose properties. Then click on in the properties Event tab and then the On
Click button at the left of the On Click field . Then Choose the code builder
and use the following code:

Private Sub Listbox_OnClick()

Me.Requery


End Sub

Kimon note that the top line of your new code and the bottom line are
already there so just add the Me.Requery in between like the example and that
should do it.



Dennis
 
P

Perry

The story is'n't clear:

So from yr last msg I see that "test2" is a subform ikn "test1"
Listbox "field" is hosted in test2.

Where is the new record added ?
Is this added in another form?
Does the other form (for new records) bound to same recordssource
your "field" listbox in "test2" is bound to?
So if the other form is unloaded, and yr back "test1" is yr "field" listbox
in subform "test2" not updated?

If above scenario isn't covering yr situation, give some more info...
Krgrds,
Perry
 
G

Guest

I want to inform that :

I have a form (eg. TEST1) wich contains a subform (e.g. TEST2)
and i use another form TEST3 for adding new values in the file of the ListBox.
The form TEST3 opens with a button in the form TEST1.

I work (add a record) in the main form (TEST1) and then i add also records
in the sub form (TEST2) and in the Listbox of the TEST2 which contains values
but not the one i want to choose.

In the Main form TEST1 there is a button which opens the form TEST3 for
adding new values in the same file of the ListBox which is in the form TEST2.

When i save the record and close the form TEST3 i click in the Listbox of
the form TEST2 (The forms TEST1 and Subform TEST2 are already open in the
adding mode) the list doesn't contain the new value that i added in the form
TEST3.

This also happens when i edit a record in the same forms (TEST1 and sub
TEST2).

****I have already used the command me.requery in the click property of the
LIstbox but it does't work.

-
Kimon
 
G

Guest

I have already used the command me.requery in the OnClick property of the
Listbox but it does't work
 
G

Guest

Hi,

I found the solution.

I (Ctrl+C) copied the rowsource property of the listbox of the secondary
form and then in the onenter event i wrote :

me![fldname].rowsource = ""
me![fldname].rowsource = "(Ctrl+V) i pasted here the rowsource of the listbox"

**I didn't wrote the command me![fldName].requery because the command
rowsource execute it automatically.
 
G

Guest

I'm using a contact form with several combo-boxes for relationtypes (fe
private, business,) their profession and so on.
Within the main form I have a button which opens a form to alter/add the
linked table for these kind of information.
So lets say I am entering a new contact and the profession of this contact
is not within my list, so while having the main form open, I click the button
and open the form allowing me to enter the new profession. After closing this
form the new profession is not within my drop-down list on the main form. I
have worked it around by adding a vb to the onactivate property of the main
form. This vb does requery all combo-boxes. This results in a refresh of all
information required.
Private Sub Form_Activate()
DoCmd.Maximize
Me.FindCompanyName.Requery
Me.FindProfession.Requery
end sub.
 

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