Solved Prevent combobox overwriting existing values. (1 Viewer)

HillTJ

To train a dog, first know more than the dog..
Local time
Today, 09:46
Joined
Apr 1, 2019
Messages
731
Hi, i have a bound combobox on a form that gets its data from a query and displays the record as continuous on a subform. My intention is to populate the combobox with only the latest 'revision status' of a record. However, what happens is that clearly an existing record may be superceeded and no longer present in the query so is not shown on the form. I'm thinking of creating an unbound combobox to capture the 'latest' lookup data then using the 'onchange' event of the unbound combo to check whether populating the bound field is empty or not. If empty it copies the value from the unbound combo across. Is this a reasonable approach?. Appreciate any assistance or even a code example. Thanking you in advance.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 13:46
Joined
Oct 29, 2018
Messages
21,473
Hi. It's hard to say without seeing your form. Can you post a screenshot?
 

bastanu

AWF VIP
Local time
Today, 13:46
Joined
Apr 13, 2010
Messages
1,402
I would use a different approach: populate the bound combo box with a table/query that includes all possible choices (so all records have a "status") then in the Enter event of the combo you switch its rowsource to a "restricted" one to only allow valid choices as of its current status then in the Exit event you reset it to the more inclusive one.

Cheers,
Vlad
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 04:46
Joined
May 7, 2009
Messages
19,242
I think it will "blank out" fields who's values are not in the rowsource of the combo when you "enter" the control.

but there is a hack, somewhat similar to your first post.
 
Last edited:

HillTJ

To train a dog, first know more than the dog..
Local time
Today, 09:46
Joined
Apr 1, 2019
Messages
731
Arnelgp, you are correct. I'll post a screenshot of the form in design view so you can see the layout.
 

HillTJ

To train a dog, first know more than the dog..
Local time
Today, 09:46
Joined
Apr 1, 2019
Messages
731
Guys, have a look @ the screenshot attached. Hope it helps.
Screenshot.jpg
 

bastanu

AWF VIP
Local time
Today, 13:46
Joined
Apr 13, 2010
Messages
1,402
Sorry, a bit lost here, what exactly are you showing here? Have you tried what I suggested? You said it is a continuous form that is "blanking out" fields, can you please show us that? The best would be for you to post a sample db illustrating your issue with just a couple of dummy records.

Cheers,
Vlad
 

HillTJ

To train a dog, first know more than the dog..
Local time
Today, 09:46
Joined
Apr 1, 2019
Messages
731
Bastanu, i'll try to explain again, be patient!. I have a form with a linked subform. The subform displays training courses that are assigned to the job (main form). This works fine. Now to assign a new course i use a bound combobox, which upon selection populates the other fields of the subform. No problems. However, the combo box gets its data from a query that populates with only the latest revision (uses max to return only the latest revision of the document). This works too,but it clearly will not populate a 'superseded ' revision selected in an earlier record (its a continuous form) as that record is no longer present in the query. I was thinking of using an unbound combobox to select the document and only populate the other fields if they contained a 'null' that way it would not overwrite the existing field with a 'null' . Arnelgp has hit the nail on the head with his post #5 and alluded to a work around? I am sure your technique would work but you're moving a bit beyond my understanding. I'd like to get this concept into my head as it'll reoccur similarly with other forms. Appreciate a bit more tuition.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 04:46
Joined
May 7, 2009
Messages
19,242
there is always a penalty for the hack, I want you to discover it.
under the cboTraining, there is a Textbox, same height, almost same width
same top and left of combo.
see the controlsource of textbox
see other events on the subform.
 

Attachments

  • comboOnContinuous.zip
    36.2 KB · Views: 210

HillTJ

To train a dog, first know more than the dog..
Local time
Today, 09:46
Joined
Apr 1, 2019
Messages
731
Arnelgp, thanks once again. Will give it a go when i get some time & let you know.
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 21:46
Joined
Jul 9, 2003
Messages
16,282
However, the combo box gets its data from a query that populates with only the latest revision

I usually tackle this problem with a pop-up form. See attached..

Here's a very nice example of the technique which I did in answer to another question a couple of a couple of years ago.

12) - Checklist With Multiple Choice - Nifty Access

 

Attachments

  • NiftyAccessComboboxPopup.zip
    37.4 KB · Views: 204

bastanu

AWF VIP
Local time
Today, 13:46
Joined
Apr 13, 2010
Messages
1,402
Please have a look at the attached, I used Arnel's example.
Cheers,
Vald
 

Attachments

  • comboOnContinuous_Vlad.zip
    89.4 KB · Views: 217

HillTJ

To train a dog, first know more than the dog..
Local time
Today, 09:46
Joined
Apr 1, 2019
Messages
731
Vlad, Yes. You're example is exactly what I need.I added a couple of revisions to 'Loto' and they were properly replicated in the combo box without removing records of earlier versions. Problem is I don't really understand how you achieved this & don't understand the relationships that start with Msys.......... Also how does access prioritise revisions that are not numbers? If you have the time, Id really like to forward a copy of my database so you can see what I've done. Really appreciate the support from all forum members who contributed. Really encouraging.
 

bastanu

AWF VIP
Local time
Today, 13:46
Joined
Apr 13, 2010
Messages
1,402
Sure, you'll find my contact email on my site in my signature, please zip it and remove any confidential info. I am not sure what you mean by "relationships that start with msys", basically the way it works is that originally the combo must be based on the "most inclusive" record set which usually is the table (or a query based on it with no criteria if you need to apply certain custom sorting). That way when you open the form all records are showing. Now when you edit or add a new record you want to force the users to select the latest revision; you do that by switching the row source of the combo in its Enter event (in the example that was the qryLatest.....). And finally after the user picks the appropriate entry you reset the row source of the combo back to its original "most inclusive" one so all the older records show up.

Cheers,
Vlad
 

HillTJ

To train a dog, first know more than the dog..
Local time
Today, 09:46
Joined
Apr 1, 2019
Messages
731
Vlad, Appreciate it works a treat. When I look at the relationships under the relationships tab, I see 3 linked tables called 'MsysNavPaneGroup...'. I don't see those tables in my form?.
 

bastanu

AWF VIP
Local time
Today, 13:46
Joined
Apr 13, 2010
Messages
1,402
Glad to hear it works for you!. Rest assure those relationships have nothing to do with how it works, they are probably defaults (msys is the prefix for the Access system tables and usually they are not visible unless you switch on "Show System Objects" under the Options/Current Database/Navigation).
Cheers,
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 04:46
Joined
May 7, 2009
Messages
19,242
did it really worked?
I click on Each record's combo and it is "blanking" the other combos.
this is not what I proposed.
 

deletedT

Guest
Local time
Today, 21:46
Joined
Feb 2, 2019
Messages
1,218
did it really worked?
I click on Each record's combo and it is "blanking" the other combos.
this is not what I proposed.
Yes, It was the same here.
But thought if OP is satisfied no need to mention it.
 
Last edited:

bastanu

AWF VIP
Local time
Today, 13:46
Joined
Apr 13, 2010
Messages
1,402
@arnelgp and Tera, would you please explain (maybe with some screen shots ) what do you mean by "blanking" the other combos. I thought there was only one combo in your example arnelgp and that is what I was trying to do. Sorry if I misunderstood the issue....

Cheers,
 

deletedT

Guest
Local time
Today, 21:46
Joined
Feb 2, 2019
Messages
1,218
@arnelgp and Tera, would you please explain (maybe with some screen shots ) what do you mean by "blanking" the other combos. I thought there was only one combo in your example arnelgp and that is what I was trying to do. Sorry if I misunderstood the issue....

Cheers,

Simply open the file and try to add new records. The first two records training changes to blank.

2020-04-28_16-11-57.gif
 

Users who are viewing this thread

Top Bottom