![]() |
|
|
#1
|
|||
|
|||
|
I have 2 tables. One is dockets and the other is tasks. Each docket could have many tasks. The primary key in dockets is DSerialNumber. The relationship is to TSerialNumber. I have a form with a combo box. If the user wants to add a task for a certain docket he chooses the correct serial number from the combo. Then it is supposed to add a record to the task (child) table based on that serial number. It does so with the insert sql command. But I want to open a form to fill out the rest of the fields and I am having a problem passing the variable to the form.
It seems to me that when I open the form only the sn has the right value. The openargs is null as well as the TSerialNumber. The insert SQL command is creating a new record with the Tserialnumber. The form is saving a new record with the rest of the fields. How can I get the form to fill the record that is created by the Insert command. I assumed the dlookup would get me to the right record. I have a command button on a form to add a task Private Sub AddTaskBttn_Click() Dim Result As String Dim Sn As String Sn = Me.cmbDSerialNumber.Column(0) DoCmd.SetWarnings False DoCmd.RunSQL "Insert Into Tasklist( TSerialNumber ) Select '" & Sn & "' As Expr;" Result = DLookup("[TSerialNumber]", "TaskList", "[TSerialNumber]='" & Sn & "' ") DoCmd.OpenForm "Task", acNormal, , "TaskList.TSerialNumber" = Sn, acFormAdd, acDialog, Sn DoCmd.SetWarnings True End Sub On the task form I have the following procedure Private Sub Form_Load() If Not IsNull(Me.OpenArgs) Then Sn = Me.OpenArgs Sn = Me![TSerialNumber] Me![TSerialNumber] = Me.OpenArgs Me.Requery End If End Sub |
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Variable Criteria | JamesLens | Queries | 0 | 01-02-2009 01:55 PM |
| Passing Values | dromorkid | Forms | 0 | 11-25-2008 02:04 PM |
| Passing a value from a variable to an update query | MUKUDU99 | Programming | 0 | 08-24-2008 09:14 PM |
| Variable question | synapse5150 | Programming | 1 | 07-09-2008 06:17 AM |
| Passing parameters to a report | elmousa68 | Access | 0 | 12-06-2006 10:38 PM |