Results 1 to 9 of 9
  1. #1
    megs is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2012
    Posts
    5

    Adding "10" to a previous record when a new record is created

    Hi,

    I want to be able to add 10 incrementally when I create a new record in a subform from the previous record. Ideally, then when a new record is created from the main form the field in the sub form goes blank. Then the process is repeated, so that when a new subform record is created it adds 10 incrementally again.

    I did play around with VBA and macros but to no avail. I am VERY new to coding.



    Thanks!!!

  2. #2
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    Can you post a screenshot of your Form - and tell us what field in what table you are wanting to add 10 to?
    We'll need more details to be able to help.

  3. #3
    megs is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2012
    Posts
    5
    Here is a screenshot of the form:Attachment 8464
    Here is a screenshot of the relationships:Attachment 8466

    I want to increment the field "Quadrat" in the sub-form Quadrat flower Survey by clicking the Add record button by muliples of ten: 0-250 (however it is not always 250). Then when you select a new transect in the "find transect" field at the top of the main form the Quadrat field automatically returns back to 0.... ideally but if it always adds 10 to the previous record

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Hi,

    Your screenshots did not get attached.

  5. #5
    megs is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2012
    Posts
    5
    sorry don't know why it did that... the preview worked fine for me :S

    Click image for larger version. 

Name:	screenshot relationships.jpg 
Views:	9 
Size:	71.1 KB 
ID:	8480

    Click image for larger version. 

Name:	screenshotform.jpg 
Views:	11 
Size:	116.3 KB 
ID:	8481

  6. #6
    amrut is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Location
    India
    Posts
    616
    Try following code in the subform's after update event -
    With Me.YouControlName
    If Not IsNull(.Value) Then
    .DefaultValue = """" & .Value + 10 & """"
    End If
    End With

    Looking at table relationships, Quadrat in your Quadrat_flower_count table is related to primary key of your Quadrat_Id table ( which will be unique for each record). In that case you cannot change that value.

  7. #7
    megs is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2012
    Posts
    5
    The coding works for me but it doesn't create a new "Quadrat ID" when I add a new record. Is this the problem you are referring to when you say "Looking at table relationships, Quadrat in your Quadrat_flower_count table is related to primary key of your Quadrat_Id table ( which will be unique for each record). In that case you cannot change that value."

    By I cannot change that value do you mean that the Quadrat ID primary key value? It was changing for me before I put in the coding.

    I also didn't include the whole relationship diagram for some reason, but have got carried away. Here is the final version:

    Click image for larger version. 

Name:	relationshipsnew.jpg 
Views:	5 
Size:	73.3 KB 
ID:	8491


    Thanks a MILLION!!


    Quote Originally Posted by amrut View Post
    Try following code in the subform's after update event -
    With Me.YouControlName
    If Not IsNull(.Value) Then
    .DefaultValue = """" & .Value + 10 & """"
    End If
    End With

    Looking at table relationships, Quadrat in your Quadrat_flower_count table is related to primary key of your Quadrat_Id table ( which will be unique for each record). In that case you cannot change that value.

  8. #8
    amrut is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Location
    India
    Posts
    616
    Is Quadrat Id (Primary key) in the QuadratID table an autonumber field or you are assigning it ? Is that field always in a multiple of 10 ? According to the table relationships, you may not be able to increment (control) it. It will be automatically added to the sub-form whenever you enter data in the first field.

  9. #9
    megs is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2012
    Posts
    5
    I'm not changing Quadrat ID, that is an automatic number. I am wanting to change the field 'quadrat' only in Quadrat ID table. Quadrat ID can continue to be autonumber filled.

    Quote Originally Posted by amrut View Post
    Is Quadrat Id (Primary key) in the QuadratID table an autonumber field or you are assigning it ? Is that field always in a multiple of 10 ? According to the table relationships, you may not be able to increment (control) it. It will be automatically added to the sub-form whenever you enter data in the first field.

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

Similar Threads

  1. Replies: 4
    Last Post: 04-07-2012, 02:33 PM
  2. Replies: 1
    Last Post: 09-11-2010, 08:21 AM
  3. Replies: 0
    Last Post: 05-04-2010, 06:39 AM
  4. Creating "Edit Record" link in table column
    By joshearl in forum Forms
    Replies: 1
    Last Post: 12-25-2009, 11:17 AM
  5. Replies: 0
    Last Post: 11-03-2009, 11:42 AM

Tags for this Thread

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