Results 1 to 8 of 8
  1. #1
    Lyla is offline Novice
    Windows XP Access 2016
    Join Date
    Aug 2018
    Posts
    6

    New form contains input from previous form

    I created a form in MS acces with several subtabs that also include forms. Now whenever f I make a record, and I want to fill in a new empty record afterwards, the form will remember restrictions I made in VBA for certain variables from the previous entry. Also, whenever I enter a value for a certain field, a random value will appear in an completely unrelated field



    I have tried to fix this by using a button "new record" with both a macro and VBA:

    Private Sub Command61_Click()
    DoCmd.GoToRecord , , acNewRec
    Exit_Command61_Click:
    MsgBox "Record saved.", vbInformation, "Record Saved"
    Exit Sub
    End Sub


    but it keeps on happening. On forums, they suggested that "data entry" should be set to "yes" in all form properties, but this does not work either. I also put "no" in the form properties "order by on load" but this does not work either. Putting the property "fetch defaults" on "no" makes no difference as well.


    Anyone who can help?

  2. #2
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,157
    I think we would need to see all the code associated with the form, as it sounds as if your validation code is doing something that is setting default values on certain controls?

    You could post a stripped down zipped version of your database as that would help.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  3. #3
    Lyla is offline Novice
    Windows XP Access 2016
    Join Date
    Aug 2018
    Posts
    6
    Thank you for your response!

    The strange thing is that when I recreate the form from the table, it does the same thing. So there must be something wrong within the table?
    Could you advice me where I can check for these validation codes? I am not able to post the database unfortunately..

  4. #4
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    The 'validation' is what you referred to in your first post
    the form will remember restrictions I made in VBA for certain variables
    so you should know what they are and where they are.
    Probably in your AfterUpdate event on the form (occurs after you commit the record) you need to remove the restrictions/validations since you say you did these in code. Validations for fields that were created in the table design itself will apply regardless if the form is based on a query or the table itself, and will override code validations if those don't satisfy the table validation rules. However, the need to have validation for a field in one record but not for the same field in another record seems odd. I suspect there is an underlying design problem if this is the case.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    Lyla is offline Novice
    Windows XP Access 2016
    Join Date
    Aug 2018
    Posts
    6
    Thanks!

    So the only type of coding I have is regarding specific variables:

    Private Sub SEX_AfterUpdate()
    Select Case Me.SEX
    Case "2"
    Me.PREG.Enabled = True
    Me.GESTW.Enabled = True
    Me.BREASTF.Enabled = True
    Case Else
    Me.PREG.Enabled = False
    Me.PREG.Value = Null
    Me.GESTW.Enabled = False
    Me.GESTW.Value = Null
    Me.BREASTF.Enabled = False
    Me.BREASTF.Value = Null
    End Select
    End Sub

    Could above be the problem?

    Is there a way that will clear each subform or make sure the form will set the focus on a specific record using the "On load" property?

  6. #6
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    The issue isn't clear - at least not to me. Define the restrictions you mention. What are they?
    Fields are not allowed to be empty/less than something/greater than something?? Controls are stuck on being disabled/enabled? Also, I know what a tab is, and what a subform is, but subtab is a new one, and since a subform can be on a tab control, I'm just guessing that you're meaning a form with one or more subforms - no tab control.

    As noted by Minty, the code you're showing doesn't help to figure out what the problem is, or what's going on. BTW, please use code tags (hashtag on menu bar) for code that's more than a few lines long.

  7. #7
    Lyla is offline Novice
    Windows XP Access 2016
    Join Date
    Aug 2018
    Posts
    6
    So the restrictions I made, are not about the fields that take on certain values when another field is filled in. The restriction that I created for some fields is that after update, for a certain value, another field closes .
    I have some validation rules, but again none for the fields that give trouble.

    There are several things going on in the form when trying data entry, one is the one you mention above about controls being disabled (because the last record had this) but the most peculiar issue is some kind of wildcard where a field takes on a certain random value when another unrelated field is filled in. However I made this database as simple as possible as I am not a programmer so besides the restriction above I have not created any coding..

    I tried to use the following code on "On load" property, but this changes nothing.


    Private Sub Form_Load()
    DoCmd.GoToRecord , , acNewRec
    End Sub


    Is there any other solution for this problem?
    PS. yes I mean subform

  8. #8
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,157
    I'm afraid without seeing your database, nothing you have shown us so far would indicate a cause of your issue.

    You can strip out all the sensitive data, and replace it with a couple of dummy records John Doe, Mrs Smith etc. and let us have a look?
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

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

Similar Threads

  1. Replies: 5
    Last Post: 02-25-2016, 10:27 AM
  2. Replies: 5
    Last Post: 07-20-2015, 02:28 PM
  3. Replies: 6
    Last Post: 10-27-2014, 08:05 PM
  4. Replies: 8
    Last Post: 05-22-2014, 10:19 PM
  5. Replies: 1
    Last Post: 11-14-2012, 02:38 PM

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