Results 1 to 4 of 4
  1. #1
    Traceyann is offline Novice
    Windows XP Access 2010 64bit
    Join Date
    Aug 2012
    Posts
    7

    Form auto enter field on new record click

    Hi


    I have a form called "holiday homes" and on this form I have used a "button" to open another form called "maintenance records " linked by the pk fields "serial number". This works well, the data shows only the maintenance records for that holiday home which is correct but when I want to add a new maintenance record for a holiday home and click the arrow to add new record, the form doesnt automatically enter the serial number for that holiday home. Is there a way to do this?
    Thanks
    Tracey

  2. #2
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Are you talking about adding a new 'maintenance record' after you have the Maintenance Form already open? If so, you have to do this with a custom 'Add Record' hack.

    If the Maintenance Form is a Single View or Continuous View Form, add a Command Button to the Form, name it 'AddMaintenanceRecord' and use this code, replacing [Serial Number] with the actual name of your Control that holds the serial number.

    Code:
    Private Sub AddMaintenanceRecord_Click()
    
     'Copy serial number field to variable
    
     SN_Variable = Me.[Serial Number] 
    
     'Go to a new record
    
     DoCmd.GoToRecord , , acNewRec
    
     'Reverse the process and plug old serial number value into new record
    
     Me.[Serial Number] = SN_Variable 
    
    End Sub


    If the Maintenance Form is a Datasheet View Form, that doesn't allow for Command Buttons, you'd have to use the same code in the Double-Click event of a Textbox.

    Linq ;0)>

  3. #3
    Traceyann is offline Novice
    Windows XP Access 2010 64bit
    Join Date
    Aug 2012
    Posts
    7
    Thank you that sounds like the solution that I'm looking for.

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Glad we could help!

    Linq ;0)>

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

Similar Threads

  1. Replies: 7
    Last Post: 08-16-2012, 02:16 PM
  2. Replies: 6
    Last Post: 04-27-2012, 01:31 PM
  3. Can I Enter Sub Name In On Click Property?
    By Soule in forum Programming
    Replies: 2
    Last Post: 03-05-2012, 11:01 PM
  4. Replies: 9
    Last Post: 06-20-2011, 03:42 PM
  5. Replies: 7
    Last Post: 01-12-2011, 08:59 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