Textbox afterupdate event preventing combobox dropdown

vicissitude

Registered User.
Local time
Today, 13:57
Joined
Feb 28, 2010
Messages
92
Hi all,

I have been trying everyway i can think of to sort this out but no luck, if someone could help me it would be much appreciated.

I have a textbox then a combobox in a line, the textbox afterupdate event code prevents the combobox from dropping down on first click.The textbox afterupdate event prevents it. So the combobox has to be double clicked before it will move.

Is there any way to get the combobox to dropdown on first click?
 
What code do you have in the AfterUpdate event of the textbox that you think is preventing the single click?
 
Dim ObjID As Long
ObjID = Nz(ObjectiveID)
If ObjID = 0 Then Exit Sub

If Me.Dirty = True Then Me.Dirty = False
Me.Filter = "ObjectiveID = " & ObjID
Me.FilterOn = True
Me.Parent!ObjectiveSelect.Requery
Me.Parent!ObjectiveSelect = ObjID

Where ObjID is the autonumber field that is generated when new record is put in, ObjectiveSelect is a listbox, and the form is a subform.
 
Sorry not ObjID but ObjectiveID a textbox which the autonumber field of a table is taken from
 
I had to put this code in the afterupdate event:

Dim ObjID As Long
ObjID = Nz(ObjectiveID)
If ObjID = 0 Then Exit Sub

If Me.Dirty = True Then Me.Dirty = False
Me.Filter = "ObjectiveID = " & ObjID
Me.FilterOn = True

which was to get the newly generated objective id of a new record and then filter the form to it. If i did not do that then the form would go to a different record for some reason
 
Maybe you can upload a copy of your db with some (short) instructions on how to reproduce the problem.
 
Thanks for the help, will try and keep this short! :)

1. If you open the 'Updates' form which should open automatically.

2. And then press the command button 'New Objective'

3. And Enter something in the combo field 'Objective Type' and then something random in the text field 'Objective Name' and then immediately go to 'Objective Status' field combo, it does not drop down because of the afterupdate event triggered by the 'Objective Name' textbox.

Hope that made sense,

So the question was is there any way to stop the after udate event of the text box messing with the next combo box?
 
Last edited:
On my system if i dont have that code in there then the subform jumps to an existing record when you are wanting it to stay on the new record.
 
It seems your subform was corrupted so in order for me to track the problem I commented out some of your code. I don't see why you're "disconnecting" and "reconnecting" the subform and maybe that could have been part of or the cause of corruption. Just a guess! What is the point of disconnecting and reconnecting the subform? Maybe we can advise of a different approach.

I created a new subform and added a few lines of code so you will need to go through your code to spot what was added or removed (i.e. commented out). It's clearly stated on there anyway, like this ADDED =========== or REMOVED ============.
 
Last edited:
Corrupted?

I disconnected and reconnected the subform because the database is being used over a network and it is very slow if Form/SubForm1/Subform2 are all connected and you try to cycle through the records.

So I thought...Disconnect and cycle through the records quickly and then select the relevant info on the listbox you want to update.

Downloading now....
 
Yep, it got corrupted. If you enable the navigation bar for that subform, you will notice that after entering a new record it stays on that record number however the record itself jumps to the first record that existed. That indicated it wasn't a coding but corruption.

Oh, I forgot to tell that I moved the other inner subform from the Objectives subform to the main form. Plus I set the Records Cycle to Current Record for the Objectives subform.
 
Thanks! that looks a lot cleaner.

Is it a best avoided to have form/subform/sub-subform and better to do it like you did with 2 subforms on main form? (thanks, i did not know you could do that)

Ok so use the after insert event instead to upate listbox, and the records don't jump now excellent.

I may still have to disconnect subform if it still runs slow over the network, i dont think it was this that was causing the corruption, it was jumping records before i added this.
 
Just a matter of preference really. If you think about it it's much easier to reference your parent form instead of Me.Parent.Parent, it cuts out that one step deep.

Yes, instead of requerying the listbox everytime any of the controls is updated you do it when all have been updated. It makes sense to do it this way especially for new records because a new record will not be saved in the database until you move to a another record which caused the Form's After Insert event to fire. It was the corruption that was causing the jump.

Have you looked at using the subform's Filter event? So when you load the form instead of disconnecting and reconnecting, just filer it to an impossible ObjectiveID such as 0.
 
Tried setting the subform filter to ObjectiveID = 0. This worked well, was a fair bit slower cycling the records than the breaking and reconnecting the linkmasterfields/linkchildfields but probably not enough to make it a problem on the network.

Thanks again for all your help.
 
If it's a fast network it should do ok. Maybe you should revert back to your other method if you feel it's slower.

Glad you got it all working!
 

Users who are viewing this thread

Back
Top Bottom