Results 1 to 3 of 3
  1. #1
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Flag a field (2000)

    You could put similar code in the Before Update event of each of the text boxes, but it will fire after the user has edited the contents, just before moving to another control or record. You can test if it's a new record:

    Private Sub ClientName_BeforeUpdate(Cancel As Integer)
    If Not Me.NewRecord Then
    If MsgBox("Are you sure you want to save changes?", vbQuestion + vbYesNo) = vbNo Then
    Cancel = True
    Me.ClientName.Undo
    End If
    End If
    End Sub

  2. #2
    5 Star Lounger
    Join Date
    Jan 2001
    Posts
    1,119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Flag a field (2000)

    I found the following code:

    Private Sub Form_BeforeUpdate(Cancel As Integer)
    Dim intReturn As Integer
    Dim strPrompt As String
    strPrompt = "Are you sure you want to edit this record?"
    intReturn = MsgBox(strPrompt, vbQuestion + vbYesNo)
    If intReturn = vbNo Then
    Cancel = True
    Me.Undo
    End If

    End Sub

    What I am trying to do is to use similar code behind a field. I have two fields on a form that people will be using to search on - client number and client name. When they put their cursor in either of these fields, people have a tendency to overwrite the field instead of clicking on the search icon to type in the search criteria. I would like the code above to come back and ask them if they are sure they want to edit this field if it is an existing record. If it is a new record, I don't want anything to happen. How would I edit the code above to do this? Would the code be in the before update event of each of the fields or behind the form? Thanks for your help.....

  3. #3
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Flag a field (2000)

    I personally avoid the double-use of a field as both a data control and a search control. I find it confusing for the user, and the possibility for error (as you've found out) is extremely high. I'd either put 2 small combo boxes in form header to select a client, or when they click that search icon I'd just pop-up a search form (this choice allows you to offer other search methods as well, like by address, etc.).
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •