Results 1 to 5 of 5
  1. #1
    jeoku is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2013
    Posts
    20

    Add Record and a Specified Field


    Hi,

    I am using a form to add a record to a table and need to be able to specify one of the fields in the table that will be added to. This field is predetermined by another form selection. If there is a way to force a value on a title box with a control source this would also do the trick.

    Thanks.

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    you can set the value of any field by having code like this:


    Field_Name = "TEST TEXT"

    if the value is a text field

    Field_Name = 12345

    if the value is a numeric value

    etc.

    you just have to make sure your field is LOCKED and it is only populated after the person has made the appropriate choice in their data.

    if you are trying to store a calculated value i'd caution you against that. There's no reason to store calculated values as they can be performed at the run time of any query/report/form.

  3. #3
    jeoku is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2013
    Posts
    20
    I think I would have to set the value of the field after I add the new record. Since I can't use the wizard what would be the code to add a new record first? And then I would use your suggested code to set that particular field.

  4. #4
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    if you're using a bound form you don't have to specifically create a record, it's started as soon as you put data in any field of that record.

  5. #5
    jeoku is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2013
    Posts
    20
    I got some help and was able to figure somehting out. Here is what I did. It creates a blank record with just the specified field, and then I can go back and edit that particular record.

    Private Sub AddSubmittal_Click()
    Dim dbs As Database
    Set dbs = CurrentDb
    dbs.Execute "INSERT INTO [Submittals] ([Project Title]) VALUES " & "('" & Me.Text26 & "');"
    dbs.Close

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

Similar Threads

  1. Replies: 2
    Last Post: 12-21-2012, 01:57 PM
  2. Replies: 6
    Last Post: 04-17-2012, 10:32 AM
  3. Replies: 3
    Last Post: 08-26-2011, 12:11 PM
  4. Creating unique record from record and field data
    By arthurpenske in forum Access
    Replies: 3
    Last Post: 08-24-2011, 06:11 PM
  5. Replies: 2
    Last Post: 03-25-2011, 12:22 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