Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2004
    Posts
    90

    Unanswered: Anyone please help - how to create msg box?

    hello everyone,

    I have the problem regarding to create msgbox after user key in data in textbox (lost focus-event).

    the problem how to create msgbox when the data entered hasn't in database record.Msgbox also will be appear while the same number enter twice or more.Any idea please help. your help will appreciated.

  2. #2
    Join Date
    Feb 2004
    Posts
    533
    Check the recordset value against the Form value. Use recordsetClone to obtain copy of recordset and Bookmark to move to the record number of that set on the form. If the values differ then show the message.

    Code:
    Private Sub Text2_LostFocus()
       ' check if form entry has occured
       If Me.Dirty Then
          curVal = Me!Text2 'Refer to name of control
          'Set recordset to the same record
          Set rst = Me.RecordsetClone
          rst.Bookmark = Me.Bookmark
          dbVal = rst.Field1 'Refer to name of Recordset field
          ' check if value has changed
          If curVal <> dbVal Then
             ' Display message box
             msg = "You have Entered: '" & curVal & "' on the Form"
             MsgBox msg
          End If
       End If
    End Sub
    /
    ~

    Bill

  3. #3
    Join Date
    Nov 2004
    Posts
    90
    how can I check the field name of recordset..anybody please help...ur'll be appreciated.

  4. #4
    Join Date
    Nov 2004
    Posts
    90
    I have entered that code but the debug message told that the value (curVal)is not define.So how can I define it?

  5. #5
    Join Date
    Feb 2004
    Posts
    533
    If you have "Option Explicit" at the top of your module you have to Dimension (define) your variables, otherwise you'll get an error like the error you got. So either remove option explicit from your module and let access figure out the variable type (The lazy Way, like I did) Or Dim the variables at the top of your procedure.

    Dim rst as Recordset
    Dim curVal as String
    Dim dbVal as String

    May need to use (Dim rst as DAO.Recordset) if ADO library referenced.

    Also you'll have to change the field names in the code to match the control / field names of your database.

    .
    ~

    Bill

Posting Permissions

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