473,326 Members | 2,136 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,326 software developers and data experts.

Require Selection in Combo before Running a Save Macro.

I would like all combo boxes to have require data before the following macro is run from a button:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command128_Click()
  2. Dim Msg, Style, Title, Help, Ctxt, Response, MyString
  3. Msg = "Please Verify Work Stream and Process"   ' Define message.
  4. Style = vbYesNo + vbInformation + vbDefaultButton2   ' Define buttons.
  5. Title = "Verify Data"   ' Define title.
  6. Help = "DEMO.HLP"   ' Define Help file.
  7. Ctxt = 1000   ' Define topic
  8.       ' context.
  9.       ' Display message.
  10. Response = MsgBox(Msg, Style, Title, Help, Ctxt)
  11. If Response = vbYes Then   ' User chose Yes.
  12.    DoCmd.RunMacro ("Save")  ' Perform some action.
  13. Else   ' User chose No.
  14.    MyString = "No"   ' Perform some action.
  15. End If
  16. End Sub
I've the Table has it required and the form has a validation rule of IS NOT NULL, However it still allows to move on and and error message is not sent.
Feb 15 '10 #1
2 1735
Stewart Ross
2,545 Expert Mod 2GB
Hi. You should use the BeforeUpdate event of the form as the location of your validation checks, as you can cancel the update if you find that all required fields are not yet filled. Cancelling the update is done by setting the Cancel argument (supplied in the parameter list of the BeforeUpdate event header) to True before you exit the sub.

There is not normally a need for an explicit call to save a record if you use this approach, as the BeforeUpdate event occurs when a user has updated a record and moves to another, or closes the form (both of which, as you have found, bypass users pressing any 'Save' button you put on the form).

-Stewart
Feb 17 '10 #2
I applied the before update event procedure.

I used a Cancel Event with Condition is Null and then Msgbox to warn then did a GotoRecord Next if condition is not null.

Works out well.

However the issue arises if I have a hidden form in the back. It doesn't pick up the active forms components.
Feb 18 '10 #3

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

Similar topics

7
by: Megan | last post by:
Hi everybody- I inherited a database that somehow uses a bound combo box as a record selector. Let me give you some background. The form is based on data from 2 tables. The first table, Person,...
1
by: meganrobertson22 | last post by:
Hi Everyone- I am trying to use a simple macro to set the value of a combo box on a form, and I can't get it to work. I have a macro with 2 actions: OpenForm and SetValue. I can open my form,...
5
by: STeve | last post by:
Hey guys, I currently have a 100 page word document filled with various "articles". These articles are delimited by the Style of the text (IE. Heading 1 for the various titles) These articles...
1
by: Brad Allison | last post by:
This is a newbie question. I have a combo box in where the end user will select an item (an obedience class - yes for dogs, not for developers) and then assign an obedience judge to that class. ...
17
by: ApexData | last post by:
Hello I have a single form, and want to require the user to make a selection from a serialnumber ComboBox before being allowed to enter any other textboxes. Also, the user should be allowed to...
1
by: zack | last post by:
I am really struggling to get to grips with this issue, would grateful for any advice. I have a form 'Applicant_Person' with various student contact data. There is a combo box to 2 options of...
5
FOE2272
by: FOE2272 | last post by:
I have tried every option that I can think of and most of them on this forum. The closest that I got was to bring up the field but it changed the other records based on what was chosen in one...
3
by: wideasleep | last post by:
Hello Everyone, I am looking for a way to trigger specific subforms to come up in a form through a combo box selection. For example purposes my selection in the combo box is CCP-03-081-FRM-14. The...
6
by: Dave | last post by:
I want to put the information that the user selects in my combo boxes into a subform that lies on the same form as the combo boxes. Thanks for your help already, Dave
3
by: flymo | last post by:
Hello All, I've bee trying out access 2007 and have a weird issue and would like to see if I'm issing something really basic. I have a form based on a query, I create a combo to look for records...
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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.