problems with requering combo boxes

  • Thread starter Thread starter JulieD
  • Start date Start date
J

JulieD

Hi

I have form with a combo box called CompanyID - which the user can select
from or, if the item isn't in the list, i have code that opens the Company's
form (double click event) and they can add the company. I then close the
form and would like to see the new company in the combo boxes list.

i am using Me.CompanyID.Requery
but it doesn't seem to work all the time, if they go to add the company
again and then close the form (without doing anything) the company will be
there in the list.

Code is
Dim stDocName As String
Dim stLinkCriteria As String

If IsNull(Me.CompanyID) Then Me.CompanyID = 0
stDocName = "FRM_Company"
stLinkCriteria = "[CompanyID] = " & Me.[CompanyID]
DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormEdit
Me.CompanyID.Requery


Any assistance would be gratefully received. PS i'm using Access 97

Cheers
JulieD
 
If you only open the Form "FRM_Company" for adding new
Companies, try:

****Untested****
Dim stDocName As String

stDocName = "FRM_Company"
DoCmd.OpenForm stDocName, , , , acFormAdd, acDialog
DoEvents
Me.CompanyID.Requery
********

HTH
Van T. Dinh
MVP (Access)
 
Hi Van
thanks for your response - however, i'm getting the error message
"You must save the current record before running the requery action"
if i put a breakpoint on the code, the error is generated on the
me.companyid.requery line

regards
JulieD

Van T. Dinh said:
If you only open the Form "FRM_Company" for adding new
Companies, try:

****Untested****
Dim stDocName As String

stDocName = "FRM_Company"
DoCmd.OpenForm stDocName, , , , acFormAdd, acDialog
DoEvents
Me.CompanyID.Requery
********

HTH
Van T. Dinh
MVP (Access)


-----Original Message-----
Hi

I have form with a combo box called CompanyID - which the user can select
from or, if the item isn't in the list, i have code that opens the Company's
form (double click event) and they can add the company. I then close the
form and would like to see the new company in the combo boxes list.

i am using Me.CompanyID.Requery
but it doesn't seem to work all the time, if they go to add the company
again and then close the form (without doing anything) the company will be
there in the list.

Code is
Dim stDocName As String
Dim stLinkCriteria As String

If IsNull(Me.CompanyID) Then Me.CompanyID = 0
stDocName = "FRM_Company"
stLinkCriteria = "[CompanyID] = " & Me.[CompanyID]
DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormEdit
Me.CompanyID.Requery


Any assistance would be gratefully received. PS i'm using Access 97

Cheers
JulieD



.
 
Had the same problem. Try this!
If not in the list in the first form and you open the other form to add an
item. Put this code in the on Close, on the second form that you opened by
code.

Form!Formname!comboboxname.requery

Formname being the name of the first form containing the combobox.

Peter


JulieD said:
Hi Van
thanks for your response - however, i'm getting the error message
"You must save the current record before running the requery action"
if i put a breakpoint on the code, the error is generated on the
me.companyid.requery line

regards
JulieD

Van T. Dinh said:
If you only open the Form "FRM_Company" for adding new
Companies, try:

****Untested****
Dim stDocName As String

stDocName = "FRM_Company"
DoCmd.OpenForm stDocName, , , , acFormAdd, acDialog
DoEvents
Me.CompanyID.Requery
********

HTH
Van T. Dinh
MVP (Access)


-----Original Message-----
Hi

I have form with a combo box called CompanyID - which the user can select
from or, if the item isn't in the list, i have code that opens the Company's
form (double click event) and they can add the company. I then close the
form and would like to see the new company in the combo boxes list.

i am using Me.CompanyID.Requery
but it doesn't seem to work all the time, if they go to add the company
again and then close the form (without doing anything) the company will be
there in the list.

Code is
Dim stDocName As String
Dim stLinkCriteria As String

If IsNull(Me.CompanyID) Then Me.CompanyID = 0
stDocName = "FRM_Company"
stLinkCriteria = "[CompanyID] = " & Me.[CompanyID]
DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormEdit
Me.CompanyID.Requery


Any assistance would be gratefully received. PS i'm using Access 97

Cheers
JulieD



.
 
Hi Peter

i'll give it a go, just off the top of your head, do you know how to
reference a control on a subform on a tab of a form as this is where the
combo box is that i need to update and i can never seem to get the syntax
correct :)

Regards
Julie

Peter McCartney said:
Had the same problem. Try this!
If not in the list in the first form and you open the other form to add an
item. Put this code in the on Close, on the second form that you opened by
code.

Form!Formname!comboboxname.requery

Formname being the name of the first form containing the combobox.

Peter


JulieD said:
Hi Van
thanks for your response - however, i'm getting the error message
"You must save the current record before running the requery action"
if i put a breakpoint on the code, the error is generated on the
me.companyid.requery line

regards
JulieD

Van T. Dinh said:
If you only open the Form "FRM_Company" for adding new
Companies, try:

****Untested****
Dim stDocName As String

stDocName = "FRM_Company"
DoCmd.OpenForm stDocName, , , , acFormAdd, acDialog
DoEvents
Me.CompanyID.Requery
********

HTH
Van T. Dinh
MVP (Access)



-----Original Message-----
Hi

I have form with a combo box called CompanyID - which the
user can select
from or, if the item isn't in the list, i have code that
opens the Company's
form (double click event) and they can add the company.
I then close the
form and would like to see the new company in the combo
boxes list.

i am using Me.CompanyID.Requery
but it doesn't seem to work all the time, if they go to
add the company
again and then close the form (without doing anything)
the company will be
there in the list.

Code is
Dim stDocName As String
Dim stLinkCriteria As String

If IsNull(Me.CompanyID) Then Me.CompanyID = 0
stDocName = "FRM_Company"
stLinkCriteria = "[CompanyID] = " & Me.[CompanyID]
DoCmd.OpenForm stDocName, , , stLinkCriteria,
acFormEdit
Me.CompanyID.Requery


Any assistance would be gratefully received. PS i'm
using Access 97

Cheers
JulieD



.
 
I looked up help in Access97 re referring to in an expression, came up with

Forms![Orders]![Orders Subform]![Quantity]
or
The full identifier for the Quantity control would be:
Forms![Orders]![Orders Subform].Form![Quantity]

Order would be your main form name & orders subform your subform name &
quantity your combo box name.

Hope this helps!! If not I have missed the point sorry!

Peter



JulieD said:
Hi Peter

i'll give it a go, just off the top of your head, do you know how to
reference a control on a subform on a tab of a form as this is where the
combo box is that i need to update and i can never seem to get the syntax
correct :)

Regards
Julie

Peter McCartney said:
Had the same problem. Try this!
If not in the list in the first form and you open the other form to add an
item. Put this code in the on Close, on the second form that you opened by
code.

Form!Formname!comboboxname.requery

Formname being the name of the first form containing the combobox.

Peter


JulieD said:
Hi Van
thanks for your response - however, i'm getting the error message
"You must save the current record before running the requery action"
if i put a breakpoint on the code, the error is generated on the
me.companyid.requery line

regards
JulieD

If you only open the Form "FRM_Company" for adding new
Companies, try:

****Untested****
Dim stDocName As String

stDocName = "FRM_Company"
DoCmd.OpenForm stDocName, , , , acFormAdd, acDialog
DoEvents
Me.CompanyID.Requery
********

HTH
Van T. Dinh
MVP (Access)



-----Original Message-----
Hi

I have form with a combo box called CompanyID - which the
user can select
from or, if the item isn't in the list, i have code that
opens the Company's
form (double click event) and they can add the company.
I then close the
form and would like to see the new company in the combo
boxes list.

i am using Me.CompanyID.Requery
but it doesn't seem to work all the time, if they go to
add the company
again and then close the form (without doing anything)
the company will be
there in the list.

Code is
Dim stDocName As String
Dim stLinkCriteria As String

If IsNull(Me.CompanyID) Then Me.CompanyID = 0
stDocName = "FRM_Company"
stLinkCriteria = "[CompanyID] = " & Me.[CompanyID]
DoCmd.OpenForm stDocName, , , stLinkCriteria,
acFormEdit
Me.CompanyID.Requery


Any assistance would be gratefully received. PS i'm
using Access 97

Cheers
JulieD



.
 
Back
Top