Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Autofill table fields

Status
Not open for further replies.

bjbrummett

Technical User
Apr 2, 2002
3
US
I am a Newbie building a database to track personnel training. I have a table in which the user inputs a start date, and I want to use this date to auotmatically enter due dates in fields on other tables. The tables are all related by SSN, but separated by program type. On the main form, the user will enter the date and select the program type by selecting the appropriate check box. I then have a popup form with additional info for that program displayed for input, one of which is the due date. However, I would like that calculated and saved in the appropriate table. It is important to save the due date for later use. Any and all assistance will be greatly appreciated.

bjbrummett
 
I use recordset coding to apply values to different tables. An example of which:

Dim Dbs as Database
Dim Rst as Recordset
Dim Rst1 as Recordset
Dim Rst2 as Recordset

'If you are just "looking" at the table and not adding or modifying the fields, change dbOpenDynaset to dbOpenSnapShot to conserve resources
Set Dbs = CurrentDb
Set Rst = dbs.OpenRecordset("Table1",dbOpenDynaset)

'When a value has been changed or when you get the calculations you are looking for in the other form

Rst.FindFirst "[SSN] = '" & Me!SSN & "'"
'This is taking into consideration that the SSN field is a text field.

Rst.Edit
Rst!Field1 = Me!Field1
Rst!Field2 = Me!Field2
Rst.Update

Rst.Close

Make sure that you do NOT have the tables open by any subforms or you'll come up with an irritating message box saying that "Another user has modified this record, do you want to Save Changes, Drop Changes, or Paste Changes?" If you cannot deviate from this and must have the table open with a form, run an Update Query. The recordset coding allows the fields to be updated without locking the record whereas, an Update Query will lock up the table for updating.

HTH
Roy
aka BanditWk
Las Vegas, NV
roy@cccamerica.org
RLMBandit@aol.com (private)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top