Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2007
    Posts
    17

    Unanswered: Default Values In Access

    HI again, just new to this!

    In a form, how do I get the default value of a field based on another table.

    I know I can right click the control box --->properties and then enter the default value, BUT, I want the value to come from a table which has ONLY one field which is entered via a subform.

    I dont want the user to tamper with the db, so I am allowing the user to change the default value by entering it into a mini subform etc, and the value they enter I want THAT to be the default value in the other form.

    Please if you have any idea what the code would look like, let me know.

    I am pulling hair out again!!!

    Thanks!

  2. #2
    Join Date
    Oct 2002
    Location
    Leicester - UK
    Posts
    820
    I don't do alot with default values personaly but i believe that they can't reference off of their own table.

    however you can set the intial value of form controls from VBA to anything you want
    Definition of a Beginner, Someone who doesn't know the rules.

    Definition of an Expert, Someone who knows when to ignore the rules.

  3. #3
    Join Date
    Jan 2007
    Posts
    17
    Thanks for the reply but the form (generated from Table 1) is not the table that holds the default value (Table 2). Its in an independant table. How do I call that up in the form I am working on?

    The table2 is a global "yearID" throughout the DB.

    Please help!

  4. #4
    Join Date
    Oct 2002
    Location
    Leicester - UK
    Posts
    820
    yes i gave you the quick reply while i looked into the exact reply you need something like this

    Code:
    Private Sub Form_Load()
        Set rs = CurrentDb.OpenRecordset("SELECT table2.yearID FROM table2;")
    
        Me.Text0.Value = rs(0).Value
    End Sub
    Last edited by m.timoney; 01-03-07 at 06:28.
    Definition of a Beginner, Someone who doesn't know the rules.

    Definition of an Expert, Someone who knows when to ignore the rules.

  5. #5
    Join Date
    Jan 2007
    Posts
    17
    Quote Originally Posted by m.timoney
    yes i gave you the quick reply while i looked into the exact reply you need something like this

    Code:
    Private Sub Form_Load()
        Set rs = CurrentDb.OpenRecordset("SELECT table2.yearID FROM table2;")
    
        Me.Text0.Value = rs(0).Value
    End Sub
    Thanks so much I will try this tomorrow but its now gone 3am and I have to get my beauty sleep

    Thank you once again!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •