Results 1 to 5 of 5
  1. #1
    sparkyinak is offline Novice
    Windows 10 Access 2016
    Join Date
    Mar 2019
    Posts
    22

    Simple Message box when opening a Form

    I have two forms that are basically identical. One is a read only form while the other used for editing database. Is there a simple VBA that will put up a yes/no Message Box up when opening the form to caution the user they are on the editable form? If yes, form opens, if no, form closes.

    Writing VBA is not my strong suit

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,975
    Add something like this to the Form_Load event

    Code:
    If MsgBox("WARNING: This form is READ ONLY and data cannot be edited" & _
      vbCrLf & "Do you want to continue?", vbQuestion+vbYesNo, "Form is READ ONLY")=vbNo Then
       DoCmd.Close acForm, Me.Name
    End If
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    put a label on the forms:
    the Read Only form has: READ ONLY data
    the other EDIT

    you know you only need 1 form to do both:
    edit:
    docmd.OpenForm "frmMyform"

    RO:
    docmd.OpenForm "frmMyform",,,,acFormReadOnly

  4. #4
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,975
    Good point. Much better solution.
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  5. #5
    sparkyinak is offline Novice
    Windows 10 Access 2016
    Join Date
    Mar 2019
    Posts
    22
    Thanx you two. It works

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

Similar Threads

  1. Error message when opening file
    By Alan H in forum Access
    Replies: 1
    Last Post: 04-13-2016, 10:36 AM
  2. Error Message when opening Database
    By lowesthertz in forum Security
    Replies: 5
    Last Post: 03-28-2015, 07:01 AM
  3. Replies: 3
    Last Post: 07-13-2011, 02:04 PM
  4. error message when opening the database
    By dollygg in forum Access
    Replies: 1
    Last Post: 10-04-2010, 08:34 PM
  5. (simple) Expressions give error message
    By P.Hofman in forum Forms
    Replies: 3
    Last Post: 01-21-2010, 01:57 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