Results 1 to 6 of 6
  1. #1
    mbake085 is offline Novice
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    21

    SetFocus/Require Entry

    I have a check box where if it is checked the following text box is visible for data entry. Here is the code:

    Private Sub Form_Current()
    If Me.COMPONENT.Value = "Yes" Then


    Me.EXISTING_TAG.Visible = Me.COMPONENT
    Else
    Me.EXISTING_TAG.Visible = False
    End If
    End Sub

    Private Sub COMPONENT_AfterUpdate()
    Me.EXISTING_TAG.Visible = Me.COMPONENT
    Me.EXISTING_TAG.SetFocus
    End Sub

    This works fine until the box is unchecked and then it has an issue with the SetFocus because the box is no longer visible.

    How can I fix this?

    Also after the SetFocus I want to make entry required in the EXISTING_TAG txt box if the COMPONET box is checked?

    Any help is greatly appreciated, thanks!

  2. #2
    mbake085 is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2010
    Posts
    21

    Made some progress...

    Private Sub Form_BeforeUpdate(Cancel As Integer)

    If Me.EXISTING_TAG = "" Or IsNull(Me.EXISTING_TAG) Then
    MsgBox "Existing AT&T tag number is required", vbCritical + vbOKOnly + vbDefaultButton2, "MISSING DATA"
    Me.EXISTING_TAG.SetFocus
    Cancel = True
    Exit Sub
    End If

    End Sub

    This requires entry in the EXISTING_TAG txt box if the COMPONENT box is check, but I don't know how to cancel the event if the COMPONENT box is unchecked.

  3. #3
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    I have a form with a Yes/No (CheckBox) Field Y and a TextField jjj. This is what I want to do:

    1)When Y = True then jjj is Visible
    2)When Y=False then jjj is invisible
    3)The value of Y in the current Record should not determine the visibility of jjj while navigation through records e.g.
    In Record No.2 I Check Y jjj becomes visible now when I navigate to Record No 3 if the value of Y is Fase jjj should be invisible and not vissible.

    I have attached this code to:
    AfterUpdate Event of Y
    OnCurrent Event of the Form


    If Me.y = True Then
    Me.jjj.Visible = True
    ElseIf Me.y = False Then
    Me.jjj.Visible = False
    End If


    This will take of everthing that I want to do.

    if this solves your problem mark the thread solved.

  4. #4
    mbake085 is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2010
    Posts
    21
    I already was able to get it to do that as you can see from the code if the first post. My issue is if it is visible the program should check if there is any data entered in the txt box and if not it should return an error before it updates. But if the txt box is not visible it shouldn't check for data entry and update regardless.

  5. #5
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    In the code in attached to the onCurrent Event of the form add this:

    If Me.y = True Then
    Me.jjj.Visible = True
    If IsNull(Me.jjj) Then
    MsgBox "No data found type valid data"
    End If

    ElseIf Me.y = False Then
    Me.jjj.Visible = False
    End If


    Now what will happen:
    1) Check box is true Field is Visible.
    2) if you navigate away from the current Record when u have checked the check box but have not entered any data in the field u will get a prompt.

  6. #6
    mbake085 is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2010
    Posts
    21
    I got it to work with this:

    If Me.EXISTING_TAG.Visible = True And (Me.EXISTING_TAG = "" Or IsNull(Me.EXISTING_TAG)) Then
    MsgBox "Existing tag number is required", vbCritical + vbOKOnly + vbDefaultButton2, "MISSING DATA"
    Me.EXPLANATION.SetFocus
    Cancel = True
    Exit Sub
    End If
    End Sub

    Thank you for the help.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. SetFocus Problem
    By ColPat in forum Programming
    Replies: 2
    Last Post: 06-21-2010, 04:43 AM
  2. Require Urgent Help Regarding UNION and SUM
    By maddysanoo in forum Queries
    Replies: 1
    Last Post: 06-10-2010, 09:08 AM
  3. Help Require (Macro Save button )?????
    By aligahk06 in forum Access
    Replies: 1
    Last Post: 04-18-2010, 08:38 AM
  4. require help with query
    By ashiers in forum Queries
    Replies: 2
    Last Post: 04-15-2009, 08:04 AM
  5. SetFocus Issue
    By Sinjin in forum Access
    Replies: 0
    Last Post: 02-14-2008, 07:31 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