473,378 Members | 1,309 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Combo box will not refresh?

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
2 10975
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: JumpinJeff | last post by:
I have a combo box that displays contact names. The recordsource contains ID and contact names (displayed as 0;1", column count 2, bound column 1). All works well except while changing records...
7
by: Doug | last post by:
Hi I have a combo box (A) that populates a following combo box (B) based on a selection. The selection from the first combo box (A) initiates an OleDbDataAdapter routine that extracts the...
5
by: Ant | last post by:
Hi, (Winform VS2003) I have a combo box bound to a typed data set. When the form loads, the combo box is popluated using a method containing the simple code below: ------------------------...
2
by: jay | last post by:
Hi. I have created an unbound combo box in a form whose purpose is to pass parameters to a query and then requery the requery. The unbound combo box is named "ClosedFilter" The two parameters...
6
by: dcyale | last post by:
I give up. I have spent hours trying to get a combo box to update when the user types in something other than what is on the list. I have tried the refresh, notin list, bribery UGH!! The form I am...
8
by: AA Arens | last post by:
Hi I do have a products table and products-parts table in my Access 2003 database and log all services into a form. I do have at least the following two combo boxes on my form: - Choose...
1
by: keri | last post by:
I would like to have a combo box on a form that shows the results of a query, however the query is variable and i am unsure how to do this. I have NO knowledge of code so very basc instructions...
7
by: billelev | last post by:
I have a query that selects data based on a particular date. This date is selected from a combo box on a form. The data from the query is then used to generate a report. This report can be...
4
by: lulu123 | last post by:
here's my problem 1) rowsource .RowSource = "select distinct , " & "from Projects " & " where =" & Me! I have the above code, and it works fine. however, i want to make the combo box in...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.