473,320 Members | 1,732 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,320 software developers and data experts.

Require ComboBox Selection when TextBox data changes

Ok guys! My brain is just swirling after reading other questions and answers. I have a form that is used to enter quarterly inventory dates. Each quarterly date (a text box - [Qtr1Date1] for example) also has 2 corresponding combo boxes - a change reason [Qtr1Date1Reason] and a change initiator [Qtr1Date1Changer]. I've made an AfterUpdate event that changes the value of the two comboBoxes to a default value - "<Select>" and it also changes the color to direct the user's attention there (but we all know that I need a requirement of data entry).

The piece that I cannot wrap my head around - if the user does not drop down to the first combobox and then the second and make an entry - how and where do I enter the validation requirement of choosing values? I only want a msgbox to pop up if they don't enter a choice in each drop down (I don't care which order they enter the choices). Do I need a validation save button? Or can this be done when user attempts to close out of form? Maybe SetFocus if value is = <Select> ?
Sep 14 '17 #1

✓ answered by NeoPa

Ah Erika, that makes it a lot clearer thank you.

In general words then, the idea is to move the focus to the Qtr1Date1Reason ComboBox control in your Qtr1Date1_AfterUpdate() event procedure to start with. As well as that you need a Qtr1Date1Reason_Exit() event procedure in which you check that it has a .Value set. If not then it sets its Cancel parameter to True, possibly with a MsgBox() call to indicate why.

That would look something like :
Expand|Select|Wrap|Line Numbers
  1. Private Sub Qtr1Date1_AfterUpdate()
  2.     'Anything else you need
  3.     Call Me.Qtr1Date1Reason.SetFocus
  4. End Sub
  5.  
  6. Private Sub Qtr1Date1Reason_Exit(Cancel As Integer)
  7.     Cancel = IsNull(Me.Qtr1Date1Reason.Value)
  8. End Sub

5 1815
NeoPa
32,556 Expert Mod 16PB
If the Form's bound you can use the Form_BeforeUpdate() procedure. If it's not then put it wherever you're going to trigger the process that uses the data.

Unfortunately it's not clear what you're using it for or how, so I can only answer generically for now.
Sep 15 '17 #2
Hey Neo, I am not currently using BeforeUpdate - I have in the text field, an after update with the following:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Qtr1Date1_AfterUpdate()
  2.     Call LogChanges(StoreCode)
  3.     Qtr1Date1Reason = "Accounting Error"
  4.     Qtr1Date1Changer = "Accounting"
  5.     Qtr1Date1Reason.BackColor = RGB(244, 66, 113)
  6.     Qtr1Date1Changer.BackColor = RGB(244, 66, 113)
  7. End Sub
So I kind of make the user "want" to change the reason and initiator from accounting so they themselves as the accountant don't show up on the audit report - but I would ideally like the form not allow them to navigate away from the first dropdown (would say accounting error) without making a new selection, and then drop down to 2nd combo (would say Accounting) and then they can navigate away to other fields. I also tried blanking out the combo selections in the afterupdate and entering a validation rule as Not Null, but it doesn't recognize that until I click a new selection and blank it out secondarily so that didn't work.
Sep 15 '17 #3
NeoPa
32,556 Expert Mod 16PB
Hi Erika.

Your latest post tells me very little about the question. It's information. I can see that, but not information that seems to lead anywhere.

You don't seem to be directing your response to what was said in my post - except somewhat obliquely perhaps. I still have no idea about most of your circumstances. Circumstances which are germane to how one would go about doing what you ask for. What you have seems quite unusual to me. I can't guess at why what you have would make sense.

So, if I'm to be any help at all to you, I need you to think carefully about what you're doing and share that info with me in such a way that it makes sense to someone who neither has your database in front of them, nor an understanding of what job it is you're working on.
Sep 15 '17 #4
I will try again. I have a text box called Qtr1Date1. When the user changes the data in the text box, I want them be forced to select a reason of why the data was changed. The reasons are in a list called Qtr1Date1Reason. I don't want them to be able to navigate anywhere except to the reason list until they make a selection.
Sep 15 '17 #5
NeoPa
32,556 Expert Mod 16PB
Ah Erika, that makes it a lot clearer thank you.

In general words then, the idea is to move the focus to the Qtr1Date1Reason ComboBox control in your Qtr1Date1_AfterUpdate() event procedure to start with. As well as that you need a Qtr1Date1Reason_Exit() event procedure in which you check that it has a .Value set. If not then it sets its Cancel parameter to True, possibly with a MsgBox() call to indicate why.

That would look something like :
Expand|Select|Wrap|Line Numbers
  1. Private Sub Qtr1Date1_AfterUpdate()
  2.     'Anything else you need
  3.     Call Me.Qtr1Date1Reason.SetFocus
  4. End Sub
  5.  
  6. Private Sub Qtr1Date1Reason_Exit(Cancel As Integer)
  7.     Cancel = IsNull(Me.Qtr1Date1Reason.Value)
  8. End Sub
Sep 16 '17 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Seamus Hand | last post by:
I am trying to write a component maintenance application and have tables as follows Part Part # Part Description Active (y/N) as these parts are obsoleted, ie Active changes to N, then I...
4
by: gazelle04 | last post by:
I'm trying to track data changes on my database. On form I create a procedure on Before Update event to track data changes, here it is: (It also puts the username who changes the record. Dim ctl...
4
by: Mtek | last post by:
Hi, We have a combo box on our page, which gets populated via a MySQL Query in PHP. What we want to do is to print the values on the page in a table that correspond the to selection from the...
3
by: crjunk | last post by:
Hi Everyone, I have a web form that I would like to enhance. What I'd like to do is this: A user adds/edits the text in a textbox. I want the adjoining label to change color. Example: User...
2
tuxalot
by: tuxalot | last post by:
Simple question I'm sure. I have a combobox listing various company names. Below the combobox there are address, city and state boxes. When a person selects a company, can I have the address city...
0
by: Edwin Elston | last post by:
I'm new with Data Sources and am using VB.Net in VS2005, although I have VS2010 available if it matters. In previous code I just wrote queries using OleDbConnections and OleDbCommands but wanted to...
1
by: Emily Walshaw | last post by:
I'm sorry, I know this has been asked a million times, but am completely new to access and need idiot proof help. I have a database and I am struggling to get a field to update based on a combobox...
0
by: Moorthi chinna | last post by:
how to reload combobox in datagridview based on combobox selection in datagridview?
10
by: simaonobrega | last post by:
Dear Bytes community, Framework: I have created a form using the "Form Design" tool. On the form property sheet, it was added to the Record Source the table which contained the fields that I...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.