By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,491 Members | 862 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,491 IT Pros & Developers. It's quick & easy.

Combo box will not refresh?

P: n/a
I'm using Access 97 on a Windows XP computer. The combo box on the
form "form1" will not refresh after a new name is added to the list.
The "limit to list" properties for the combo box is set to yes. When
I type a clients name in the box that is not in the list, the form
"Add New Client Form" opens to add the client. When I return to the
main form, the combo box will not refresh until I click on a name in
the box and then click the refresh button, then I have to go back and
change the name in the combo box to the correct one. This is the code
I'm using the following event procedure for "On Unload" for the form
"Add New Client Form". What is missing? I'd appreciate any help!

Private Sub Form_Unload(Cancel As Integer)

Dim MyControl As Control

' If Daysheet Form (Edit Mode) is loaded, then do following:
If IsLoaded("form1 (Edit Mode)") Then

' Requery Client Name combo box, and set value of
' Client Name combo box.
Set MyControl = Forms![form1 (Edit Mode)]![cbName]
DoCmd.SelectObject A_FORM, "form1 (Edit Mode)"
MyControl.Requery
End If

' If Daysheet Form is loaded, then do following:
If IsLoaded("form1") Then

' Requery Client Name combo box, and set value of
' Client Name combo box.
Set MyControl = Forms![form1]![cbName]
DoCmd.SelectObject A_FORM, "form1"
End If

End Sub
Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies

P: n/a
Here is the way I do it:

Private Sub cboStreet_NotInList(NewData As String, Response As Integer)
Response = acDataErrContinue
DoCmd.OpenForm "NewStreetForm", , , , acFormAdd, acDialog, NewData & "%"
& Me.Name
End Sub

(I pass the name of the form as part of the OpenArgs because streets may be
added from several forms - I then parse it out as fName when I load the
NewStreetForm)

The 'Okay button on NewStreetForm has this relevant code, after saving the
new street to the street table:

Dim cbo As ComboBox
Set cbo = Forms(fName).cboStreet
cbo = vbNullString
cbo.Requery
cbo = id
Set cbo = Nothing

(id is the variable assigned to the street_id - cboStreet has two columns,
street_id and str_name)

Hope this helps.
Darryl Kerkeslager

"Lucinda Roebuck" <lu*************@ncmail.net> wrote in message
news:a2**************************@posting.google.c om...
I'm using Access 97 on a Windows XP computer. The combo box on the
form "form1" will not refresh after a new name is added to the list.
The "limit to list" properties for the combo box is set to yes. When
I type a clients name in the box that is not in the list, the form
"Add New Client Form" opens to add the client. When I return to the
main form, the combo box will not refresh until I click on a name in
the box and then click the refresh button, then I have to go back and
change the name in the combo box to the correct one. This is the code
I'm using the following event procedure for "On Unload" for the form
"Add New Client Form". What is missing? I'd appreciate any help!

Private Sub Form_Unload(Cancel As Integer)

Dim MyControl As Control

' If Daysheet Form (Edit Mode) is loaded, then do following:
If IsLoaded("form1 (Edit Mode)") Then

' Requery Client Name combo box, and set value of
' Client Name combo box.
Set MyControl = Forms![form1 (Edit Mode)]![cbName]
DoCmd.SelectObject A_FORM, "form1 (Edit Mode)"
MyControl.Requery
End If

' If Daysheet Form is loaded, then do following:
If IsLoaded("form1") Then

' Requery Client Name combo box, and set value of
' Client Name combo box.
Set MyControl = Forms![form1]![cbName]
DoCmd.SelectObject A_FORM, "form1"
End If

End Sub

Nov 13 '05 #2

P: n/a
Dont have time to read your code but this works find for me. Its on
the close button of the form. I wonder if you problem is because of
the unload event 0 never used that one 0 maybe try on close.

'Test if the frmNewDataRequest form is open. if it is then refresh
the contact
'Combo box to include the newly added record
If CurrentProject.AllForms("frmNewDataRequest").IsLoa ded Then

Forms!frmNewDataRequest![cmboContact].Requery

End If

Have fun

Lincoln
lu*************@ncmail.net (Lucinda Roebuck) wrote in message news:<a2**************************@posting.google. com>...
I'm using Access 97 on a Windows XP computer. The combo box on the
form "form1" will not refresh after a new name is added to the list.
The "limit to list" properties for the combo box is set to yes. When
I type a clients name in the box that is not in the list, the form
"Add New Client Form" opens to add the client. When I return to the
main form, the combo box will not refresh until I click on a name in
the box and then click the refresh button, then I have to go back and
change the name in the combo box to the correct one. This is the code
I'm using the following event procedure for "On Unload" for the form
"Add New Client Form". What is missing? I'd appreciate any help!

Private Sub Form_Unload(Cancel As Integer)

Dim MyControl As Control

' If Daysheet Form (Edit Mode) is loaded, then do following:
If IsLoaded("form1 (Edit Mode)") Then

' Requery Client Name combo box, and set value of
' Client Name combo box.
Set MyControl = Forms![form1 (Edit Mode)]![cbName]
DoCmd.SelectObject A_FORM, "form1 (Edit Mode)"
MyControl.Requery
End If

' If Daysheet Form is loaded, then do following:
If IsLoaded("form1") Then

' Requery Client Name combo box, and set value of
' Client Name combo box.
Set MyControl = Forms![form1]![cbName]
DoCmd.SelectObject A_FORM, "form1"
End If

End Sub

Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.