Page 2 of 2 FirstFirst 12
Results 16 to 26 of 26
  1. #16
    Macallan60 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Mar 2010
    Posts
    51
    Greetings twgonder and Gicu,

    I'm away from my computer for a while. Thank you both for your suggestions. Looking back at the posts I don't think I explained what I need clearly. For that I do apologize.

    Here's what needs to happen:

    Scenaro A:
    1. User clicks the checkbox.


    2. User enters a note in the textbox. For example "Send 5 boxes"
    3. User clicks the Save button and gets a message saying the word "Blue" or "Brown" is not in the textbox.

    Scenaro B:
    1. User clicks the checkbox.
    2. User does not enter a note in the textbox (the textbox is empty).
    3. User clicks the Save button and gets a message saying the word "Blue" or "Brown" is not in the textbox.

    Scenaro C:
    1. User clicks the checkbox.
    2. User enters a note in the textbox. For example "Use blue box"
    3. User clicks the Save button and the record is saved.

    Scenaro D:
    1. User clicks the checkbox.
    2. User enters a note in the textbox. For example "Use brown box"
    3. User clicks the Save button and the record is saved.

    Scenaro E:
    1. User does not click the checkbox.
    2. User does not enter a note in the textbox (the textbox is empty).
    3. User clicks the Save button and the record is saved (this Save button also saves other records on this form).

    I hope this helps and apologies for any confusion.

  2. #17
    twgonder is offline Expert
    Windows 10 Access 2021
    Join Date
    Jun 2022
    Location
    Colombia
    Posts
    650
    @Gicu Yep. OP had me confused as to exactly what's going on. And then, what kind of "note" is it? Long text, short text, rich text?!!!
    In any case, he has both solutions.

  3. #18
    Macallan60 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Mar 2010
    Posts
    51
    *** DUPLICATE POST. SORRY. DO NOT KNOW HOW TO DELETE ****

    Greetings twgonder and Gicu,


    I'm away from my computer for a while. Looking back at my previous posts, I don't believe I explained what I'm looking for clearly. I do aplogize.


    Here's what I'm looking to happened what the user clicks the Save button:


    Sceanro A:
    1. User checked the checkbox.
    2. User enters a note in the textbox. For example "Send 5 boxes"
    3. User gets a message that the note entered in the textbox does not contain thes words "Blue" of "Brown".
    4. Record does not save.


    Sceanro B:
    1. User checked the checkbox.
    2. User does not enter a note in the textbox (the textbox is empty).
    3. User gets a message that the note entered in the textbox does not contain thes words "Blue" of "Brown".
    4. Record does not save.


    Sceanro C:
    1. User checked the checkbox.
    2. User enters a note in the textbox. For example "Use blue boxes"
    3. Record saves (note contains the word blue).


    Sceanro D:
    1. User checked the checkbox.
    2. User enters a note in the textbox. For example "Use brown boxes"
    3. Record saves (note contains the word brown).


    Sceanro E:
    1. User does not check the checkbox (checkbox is empty).
    2. User does not enter a note in the textbox (the textbox is empty).
    3. Record saves (this Save button also saves other data on this form).


    I hope this helps and apologies for any confusion.


    Cheers
    Last edited by Macallan60; 01-06-2023 at 01:16 PM. Reason: Duplicate post

  4. #19
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,101
    Scenaro F:
    1. User does not click the checkbox.
    2. User DOES enter a note in the textbox (the textbox is NOT empty).
    3. User clicks the Save button and the record is ??????

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  5. #20
    Macallan60 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Mar 2010
    Posts
    51
    Sorry to cause so much trouble and frustration for you both. I'll look for a different solution.
    Cheers

  6. #21
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,101
    Here is some updated code, you might need to tweak it depending how your entire Save procedure is structured:
    Code:
    '2: If statement with Else updated
    If Me.chkBox = -1 Then
    	If InStr(nz(Me.txtBox,""), "blue") = 0 And InStr(Nz(Me.txtBox,""), "brown") = 0 Then 'covers Scenarios A,B,C,D
    		MsgBox "Make sure to include box color in notes (Blue or Brown).", vbExclamation, "Blue/Brown Box"
    		Me.txtBox.SetFocus
    		Exit Sub
    	End If
    Else
    'checkbox not checked
    	If Not isnull(Me.txtBox) Then
    		'scenario F
    		msgbox "You entered a note but you did not checked the box!",vbExclamation,"Blue/Brown Box"
    	Else
    		'scenario E - do nothing to allow to exit if and Save	
    	End If
    End If
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  7. #22
    twgonder is offline Expert
    Windows 10 Access 2021
    Join Date
    Jun 2022
    Location
    Colombia
    Posts
    650

    I think I got the scenarios

    Quote Originally Posted by Macallan60 View Post
    Greetings twgonder and Gicu,...
    Here's what needs to happen:
    ...
    I think the sample has you covered. Your save button should normally trigger the Form_Beforeupdate procedure.
    There are two validations, but as noted in post #12, they might not always fire off.
    Note: the user can enter just "brown" or something like "Use blue bow" (based on your scenarios).
    Modified .accdb attached.
    Attached Files Attached Files

  8. #23
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,101
    @Macallan60: no need to apologize, that is the reason we are here, no frustration on my part ...
    Give it a try and post back if you get stuck; it is always best to post the entire code (the save procedure for example including the Private Sub and the End Sub lines) so we can get a clear picture of what you're trying to achieve.

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  9. #24
    twgonder is offline Expert
    Windows 10 Access 2021
    Join Date
    Jun 2022
    Location
    Colombia
    Posts
    650
    Quote Originally Posted by Macallan60 View Post
    Sorry to cause so much trouble and frustration for you both. I'll look for a different solution.
    Cheers
    No problem here, it gave me an excuse to try the template with a different situation.

  10. #25
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    Macallan60

    I have a textbox where the user is required to enter either one of two words after placing a check in a checkbox. Those two words are Blue or Brown.
    Must the user check the box?

    I think the underlying business rules have not been stated completely. It isn't clear (to me) why the checkbox is involved.

    eg. What are the conditions for accepting a completed form?
    The user must check the checkbox
    The user must enter text in the textbox
    The entered text must include " blue " or "brown "

    Also Vlad's Scenario F needs an answer.

    Bottom line, you can not program/code the validation routine until you understand all the related business logic.

  11. #26
    Macallan60 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Mar 2010
    Posts
    51
    Quote Originally Posted by Bob Fitz View Post
    Why not use a combo box which would allow you to easily restrict what is entered rather than use a textbox.
    Do you even need the checkbox? You could just test for a null value in the combo.
    Even though it's a lot of company bureaucracy I need to go through, I've determined Bob's suggestion would work best. Thank you all for your suggestions and again I apologize for the confusion and inconvenience I caused.
    Cheers

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 10
    Last Post: 07-07-2017, 05:11 PM
  2. Replies: 3
    Last Post: 04-04-2016, 09:21 AM
  3. Replies: 9
    Last Post: 10-01-2013, 08:48 AM
  4. Bold only certain words in textbox?
    By NateHaze in forum Reports
    Replies: 1
    Last Post: 06-04-2011, 11:47 AM
  5. Textbox, remove certain words.
    By dgrzalja in forum Forms
    Replies: 0
    Last Post: 11-03-2009, 09:42 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums