Page 2 of 2 FirstFirst 12
Results 16 to 20 of 20
  1. #16
    Pgill is offline Novice
    Windows XP Access 2000
    Join Date
    Jul 2011
    Posts
    21
    Rpeare, thanks for the comments.... I have learnt something new here "Ctrl ' " handy little shortcut, thanks for that..... Why I wanted the entry from the last record in the new record is, you may only use 2 or 3 selections, but use say one selection the most.... it will automatically be placed there..... but if you do decide to use one of the other selections, you just type it in and then the next record will start with the new selection..... It is more of a time management solution than anything else..... but is something useful.
    Paul, what I have done at the moment till I can sort out something that works is to use a drop down listbox..... it is not the answer, but will help in the meantime. I will carry on looking into this problem through doing some code learning, and then I can place the answer here to teach others that may want to know.....
    Thanks a lot for the help, I will use another test base to play with this problem and try things like adding a table and Dlookup...... etc....

    God bless
    Peter

  2. #17
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    let's say you have this data set:

    Code:
    RecordID PersonID ItemID
    1       1        1
    2       1        1     
    3       1        1   
    4       1        2
    Let's assume for the sake of this question that this is the only data you have. When you go to the data entry form for record 5 (the new record) do you want the ITEMID to be filled in with 2 (the most recent ITEMID) OR do you want it to be 1 (the most used ITEMID) your last post made it muddy to me.

    In either case it can be handled on your data entry form. In the ON ENTER property of your ITEMID field you could have this code:

    Code:
    Dim db As Database
    Dim rst As Recordset
    Dim ssql As String
    
    If ItemID = 0 Or IsNull(ItemID) Then
        Set db = CurrentDb
        ssql = "SELECT * FROM tbl_Data2 WHERE (([PERSONID]) = " & Me.PersonID & " AND ([RECORDID]) < " & Me.RecordID & ") ORDER BY RECORDID DESC"
        Set rst = db.OpenRecordset(ssql)
        
        rst.MoveFirst
        ItemID = rst.Fields("itemid")
        rst.Close
        Set db = Nothing
    Else
        Exit Sub
    End If
    Which would find the most recent record by recordID and use the value in the ITEMID field to populate the current record. You can determine what gets populated by adjusting the SQL statement so that the record you want always appears first.

  3. #18
    Pgill is offline Novice
    Windows XP Access 2000
    Join Date
    Jul 2011
    Posts
    21
    Hi Rpeare,

    Thanks for the reply :-) sorry about being vague.... let me try and make it clear....

    I have designed a Treasure hunting Database...... One of the fields is called: Detector Type. In this field as in my case, I have two metal detectors a Ace 250, and a Tesoro.... The one I use the most is the Ace 250......
    Now I have two options:
    1) Create a drop down list with both detectors in it... I then use the drop down and choose the correct detector.......
    2) Or I create a txtfield, and type in record No 1, 2, Tesoro in Record No 3, Ace250....

    What I want is when I add the next new record No 4..... The last entry the Ace 250 should populate the field automatically on entry to new record.... If I do want the Tesoro, I would type it in manually,,,, then the next new record No 5 will automatically have Tesoro entered into it......

    Hope that helps?

    Thanks again for any help...

  4. #19
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    The code I posted looks at the most recent record (by primary key ID, assuming it's an autonumber) and returns the most recent value from that list other than the current record which is what you're telling me you want in your most recent post, you just have to adapt the code to your table, form and field names.

  5. #20
    Pgill is offline Novice
    Windows XP Access 2000
    Join Date
    Jul 2011
    Posts
    21
    Hi Rpeare,

    Thanks for all your help.... I have copied the code to Notepad and will create a testbase and give it a try.... This Forum is great and very helpful..... I will let you know what happens....

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 03-25-2011, 12:22 PM
  2. Populate field from field on previous record
    By randolphoralph in forum Forms
    Replies: 7
    Last Post: 03-04-2011, 11:28 AM
  3. Bolding a record in a field that is the max
    By salisbut in forum Access
    Replies: 3
    Last Post: 08-17-2010, 09:57 AM
  4. Allow change to a field on new record only
    By Grooz13 in forum Forms
    Replies: 4
    Last Post: 08-16-2010, 11:36 AM
  5. Replies: 1
    Last Post: 02-26-2009, 11:31 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