Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Posts
    294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help needed badly (Access 2000)

    Really am stumped on this. I want the user if It's a new records to be able to say yes or no to creating the new record. If they say yes I want the form to allow edits and the background color for all controls to be 16777215 if they select no then the form should not allow edits and the color should be 12632256 and undo anything they may have type in the fields. Thanks for the help....

    Dim strMsg As String

    If Me.NewRecord = True Then
    For Each Ctl In Me.Controls
    If Ctl.ControlType = acTextBox Or Ctl.ControlType = acComboBox Then
    Ctl.BackColor = 16777215

    strMsg = "Data has changed. "
    strMsg = strMsg & " Do you wish to create a new contact?"
    strMsg = strMsg & " Click Yes to Save or No to Discard changes."
    If MsgBox(strMsg, vbQuestion + vbYesNo, "Save Record?") = vbYes Then
    Me.CreatedBy = CurrentUser()
    Me.DateCreated = Date
    Forms![frm_SiteContact].AllowEdits = True
    End If
    For Each Ctl In Me.Controls
    If Ctl.ControlType = acTextBox Or Ctl.ControlType = acComboBox Then 'Others include acLabel, acListBox, acComboBox, acCheckBox etc
    Ctl.BackColor = 16777215
    End If
    Next
    Else

    For Each Ctl In Me.Controls
    If Ctl.ControlType = acTextBox Or Ctl.ControlType = acComboBox Then
    Ctl.BackColor = 12632256
    Forms![frm_SiteContact].AllowEdits = False
    DoCmd.RunCommand acCmdUndo
    End If
    Next

    End If

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Help needed badly (Access 2000)

    I don't know if it is possible to get it working the way you want dependably.

    Instead of letting the user enter data and then ask whether they should be saved, set the AllowAdditions property of the form to No, and provide a command button to create a new record. Pop up a separate unbound form for entering the new record, with an OK button that saves the record and Cancel button that closes the popup form without saving.

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Help needed badly (Access 2000)

    AllowEdits doesn't stop them from adding a new record, only AllowAdditions stops that, so it isn't awfully clear what you're trying to accomplish. In any case, the only place you could make something like this apply would be in the beforeupdate event of the form if the Me.NewRecord returned a True value. However, by that time, they've already entered the data and you have to cancel the update and undo the record before changing settings. . Your best bet is to take Hans' suggestion. That is the method I've always preferred and it is pretty much foolproof, since there is nothing to "undo". If they change their mind, the record simply isn't created.
    Charlotte

Posting Permissions

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