Hi,
I've been having a similar issue to what is described in the "refresh a form" post with a ComboBox that is not being refreshed after adding a new value on a seperate form. The second form is being opened via the standard DoCmd call.
I've tried adding Requery in AfterUpdate, Form_Current, etc. to no avail.... The test form has the combobox and a command button.
Here's my test code: - Private Sub cmdAddCatgCd_Click()
-
On Error GoTo Err_cmdAddCatgCd_Click
-
-
Dim stDocName As String
-
Dim stLinkCriteria As String
-
-
stDocName = "subfrmHierCatgCd"
-
DoCmd.OpenForm stDocName, , , stLinkCriteria
-
-
Exit_cmdAddCatgCd_Click:
-
Exit Sub
-
-
Err_cmdAddCatgCd_Click:
-
MsgBox Err.Description
-
Resume Exit_cmdAddCatgCd_Click
-
End Sub
-
-
Private Sub Form_AfterUpdate()
-
Me.Combo21.Requery
-
End Sub
-
-
Private Sub Form_Current()
-
Me.Combo21.Requery
-
End Sub
cmdAddCatgCd_Cl ick opens another form to maintain the code values that are populated in Combo21.
So far, the only way I've been able to get this to work is by adding a "Refresh" command button with the following code: - Private Sub Command25_Click()
-
On Error GoTo Err_Command25_Click
-
-
Me.Combo21.Requery
-
-
Exit_Command25_Click:
-
Exit Sub
-
-
Err_Command25_Click:
-
MsgBox Err.Description
-
Resume Exit_Command25_Click
-
-
End Sub
I'd prefer having the requery happen automatically for both forms and subforms.....
Thanks, Ed.
34 20221 Rabbit 12,516
Recognized Expert Moderator MVP
Hi,
I've been having a similar issue to what is described in the "refresh a form" post with a ComboBox that is not being refreshed after adding a new value on a seperate form. The second form is being opened via the standard DoCmd call.
I've tried adding Requery in AfterUpdate, Form_Current, etc. to no avail.... The test form has the combobox and a command button.
Here's my test code: Private Sub cmdAddCatgCd_Cl ick()
On Error GoTo Err_cmdAddCatgC d_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "subfrmHierCatg Cd"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_cmdAddCatg Cd_Click:
Exit Sub
Err_cmdAddCatgC d_Click:
MsgBox Err.Description
Resume Exit_cmdAddCatg Cd_Click
End Sub Private Sub Form_AfterUpdat e()
Me.Combo21.Requ ery
End Sub Private Sub Form_Current()
Me.Combo21.Requ ery
End Sub
cmdAddCatgCd_Cl ick opens another form to maintain the code values that are populated in Combo21.
So far, the only way I've been able to get this to work is by adding a "Refresh" command button with the following code: Private Sub Command25_Click ()
On Error GoTo Err_Command25_C lick
Me.Combo21.Requ ery
Exit_Command25_ Click:
Exit Sub
Err_Command25_C lick:
MsgBox Err.Description
Resume Exit_Command25_ Click
End Sub
I'd prefer having the requery happen automatically for both forms and subforms.....
Thanks, Ed.
Have you tried the solutions that were posted in that other thread?
Have you tried the solutions that were posted in that other thread?
Yes. Originally, I replied to that post to imply this but NeoPa told me I had to start a new thread so I did.
I think part of the problem I'm having is that there's no direct link between the forms. Once the second form is opened, the code being executed in the main form (DoCmd) continues to completion. It doesn't wait for the user to close the second form....
Code from Command Button to open second form: -
Private Sub cmdAddCatgCd_Click()
-
On Error GoTo Err_cmdAddCatgCd_Click
-
-
Dim stDocName As String
-
Dim stLinkCriteria As String
-
-
stDocName = "subfrmHierCatgCd"
-
DoCmd.OpenForm stDocName, , , stLinkCriteria
-
-
Exit_cmdAddCatgCd_Click:
-
Exit Sub
-
-
Err_cmdAddCatgCd_Click:
-
MsgBox Err.Description
-
Resume Exit_cmdAddCatgCd_Click
-
End Sub
-
Any ideas ?
Thanks, Ed.
Rabbit 12,516
Recognized Expert Moderator MVP
What about putting the refresh/requery code in the second form? Perhaps in the On Close event it can also refresh/requery the first form.
Denburt 1,356
Recognized Expert Top Contributor
I saw the other thread Bits and don't take offense to the tone that you might think someone came across in, we all see what is typed but what we don't see are facial expressions etc. Many times when I was a forum noob (new guy) I took a completely harmless comment or even a stern one, and thought it seemed harsh. Most of us here (if not all) are simply volunteers helping each other.
On to your issue as Rabbit stated use the "on close" event of the second form to save the record on the second form, and then requery the main forms combo box. - DoCmd.RunCommand (acCmdSelectRecord)
-
DoCmd.RunCommand (acCmdSaveRecord)
-
Forms!FirstForm!ComboBox1.requery
This should resolve your problem. Also a link to the other thread would be nice I am sure you were probably looking for a way to do that. It's the round world looking thing next to the square pic in the toolbar on top. http://www.thescripts.com/forum/thread639998.html
I saw the other thread Bits and don't take offense to the tone that you might think someone came across in, we all see what is typed but what we don't see are facial expressions etc. Many times when I was a forum noob (new guy) I took a completely harmless comment or even a stern one, and thought it seemed harsh. Most of us here (if not all) are simply volunteers helping each other.
On to your issue as Rabbit stated use the "on close" event of the second form to save the record on the second form, and then requery the main forms combo box. -
DoCmd.RunCommand (acCmdSelectRecord) DoCmd.RunCommand (acCmdSaveRecord) Forms!FirstForm!ComboBox1.requery
-
This should resolve your problem. Also a link to the other thread would be nice I am sure you were probably looking for a way to do that. It's the round world looking thing next to the square pic in the toolbar on top. http://www.thescripts.com/forum/thread639998.html
First off, thanks for the advice !
Regarding the questions I had.... If the user does not close the form even after adding a record or two, the Requery would not get executed as the Close event was not triggered ? I may have to add that to other events as well (most likely as a public routine) ?
Additionally, for every form with that combobox that calls the maint form I'm assuming I'd have to add a Requery statement for each and every form ? -
DoCmd.RunCommand (acCmdSelectRecord) DoCmd.RunCommand (acCmdSaveRecord) Forms!FirstForm!ComboBox1.requery Forms!SecondForm!ComboBox1.requery Forms!ThirdForm!ComboBox1.requery Forms!FourthForm!ComboBox1.requery Forms!SubForm1!ComboBox1.requery Forms!SubForm2!ComboBox1.requery
-
Will an error be generated if a form that's being requeried (e.g. FourthForm) is not open ?
Thanks for the help !
Ed.
Denburt 1,356
Recognized Expert Top Contributor
Why would you want so many forms open at once? That approach does not seem to be very efficient at all. You can check to see if a form is open I utilize the following function. - Function IsLoaded(strFrmName As String) As Boolean
-
Const conFormDesign = 0
-
Dim intX As Integer
-
IsLoaded = False
-
For intX = 0 To Forms.Count - 1
-
If Forms(intX).FormName = strFrmName Then
-
If Forms(intX).CurrentView <> conFormDesign Then
-
IsLoaded = True
-
Exit Function
-
End If
-
End If
-
Next
-
End Function
Then simply call the function: - if isloaded("YourFormName") then Forms!YourFormName.requery
Why would you want so many forms open at once? That approach does not seem to be very efficient at all. You can check to see if a form is open I utilize the following function. - Function IsLoaded(strFrmName As String) As Boolean
-
Const conFormDesign = 0
-
Dim intX As Integer
-
IsLoaded = False
-
For intX = 0 To Forms.Count - 1
-
If Forms(intX).FormName = strFrmName Then
-
If Forms(intX).CurrentView <> conFormDesign Then
-
IsLoaded = True
-
Exit Function
-
End If
-
End If
-
Next
-
End Function
Then simply call the function: - if isloaded("YourFormName") then Forms!YourFormName.requery
Thanks, I'll try your suggestion.
Not all of the forms will be opened at once, hence my question about when the form is not opened. The user should only have the main data entry form and the code maintenance form opened at a given time....
Thanks again, Ed.
Thanks, I'll try your suggestion.
Not all of the forms will be opened at once, hence my question about when the form is not opened. The user should only have the main data entry form and the code maintenance form opened at a given time....
Thanks again, Ed.
Hi Denburt,
A quick question. I have a routine that checks is a Form is opened already but it doesn't use a FOR loop. It uses SysCmd to check for the specified form. Is one better than the other ? -
Public Function FormIsOpen(ByVal strFormName As String) As Boolean
-
-
Const conDesignView = 0
-
Const conObjStateClosed = 0
-
-
FormIsOpen = False
-
If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> conObjStateClosed Then
-
If Forms(strFormName).CurrentView <> conDesignView Then
-
FormIsOpen = True
-
End If
-
End If
-
-
End Function
-
Thanks, Ed.
Denburt 1,356
Recognized Expert Top Contributor
I think your method would be much more efficient, thanks for posting it. A lot of my code including the code I posted travels around in my databases I start a new db and the first thing I do is import several modules and off I go. The code I posted has been with me since I started with MS Access and that was way to many years now.... I think I found it on one of Microsoft's examples somewhere.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Aaron Ackerman |
last post by:
I have a bound combobox the appears on a cell within the column of my bound
grid when the user clicks on a cell n(In my vb.net WinForm app).
I am trying to allow the adding of an item to that bound combo by allowing
the user to dynamically type in the new value directly in the combo box
whcih in turn updates the lookup table and then when they have finished
leaves that particular cell on the grid with the correct value.
Seems...
|
by: ECathell |
last post by:
I am getting an unspecified error when adding a windows form to a project. New project, old project. Doesn't matter. Also happens for user control. All the message box says is Unspecified Error.
--
--Eric Cathell, MCSA
|
by: awebguynow |
last post by:
in other words, Can I make client side mod's before I submit a form and
Post ?
I guess its just a matter of cycling through the form elements and
setting value to null (or empty string) for those that did not Change (
using onChange ).
|
by: reloader |
last post by:
Hi all,
I would like to ask you about combobox refershing. My code is:
<title>none</title>
<body>
<table border="1" width="100%" cellspacing="0" cellpadding="2">
<%
dim m_DB
|
by: BASSPU03 |
last post by:
I've set my combobox to operate according to this option:
"Find a record on my form based on a value I selected from my combobox."
When I select a value from the combobox, I can see that the record on the navigation bar changes accordingly. (Example: Select "2000" and record is 1 of 21; select 2001 and record is 2 of 21; and so forth.)
Unfortunately, when I press "Tab" from that combobox on the main form to a field in the subform and...
| |
by: billa856 |
last post by:
Hi,
My project is in MS Access.
In that I have one Form in which I have some Comboboxes.
1st one is Independent,
2nd one is dependent on first one,
3rd one is dependent on 1st and 2nd both.
After I load the form when I select an item from 1st one it will generate list for 2nd one, then I select an item from 2nd one it will generate list for 3nd one. Uptil this, all r done well.
But after these selection if I change the selection of 1st...
|
by: Mel |
last post by:
On the SERVER SIDE, I need to get some values from form Elements and
save the values into a file.
Is this possible using Javascipt ?
any exmple is highly appreciated
|
by: hollywood115 |
last post by:
Hey guys. I have a quick question... its very simple but i cant find a way to do it..
I need to add items to a combobox in a windows form... i need to have a name, and a value to go with it so they're associated with one another.
whats the easiest way i can do this? i thought of creating a new class to handle it, but im sure c# has a way of doing that already....
thanks for your help.
|
by: AccessHunter |
last post by:
Hi,
I have a continous form that displays Name and Address of Suppliers.
In the form there is a combo box for 'Active Address' and 10 other text boxes. All the fields coem from one table, "Primary Suppliers".
The combobox is for 'Active Address' with values 'Yes' and 'No'.Control source of the form is,
Select * from PrimarySuppliers where ="Yes". I want the form to display only the Suppliers who has 'Active address' = "Yes".If user selects...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |