Connecting Tech Pros Worldwide Forums | Help | Site Map

Combo box will not refresh?

Lucinda Roebuck
Guest
 
Posts: n/a
#1: Nov 13 '05
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

Darryl Kerkeslager
Guest
 
Posts: n/a
#2: Nov 13 '05

re: Combo box will not refresh?


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" <lucinda.roebuck@ncmail.net> wrote in message
news:a2d0500a.0409291101.7c6ce14b@posting.google.c om...[color=blue]
> 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[/color]


Jack
Guest
 
Posts: n/a
#3: Nov 13 '05

re: Combo box will not refresh?


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


lucinda.roebuck@ncmail.net (Lucinda Roebuck) wrote in message news:<a2d0500a.0409291101.7c6ce14b@posting.google. com>...[color=blue]
> 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[/color]
Closed Thread