Microsoft Access Forums

Go Back   Microsoft Access Forums > Access Forums > Forms

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 03-02-2009, 02:32 AM
Novice
 
Join Date: Feb 2009
Posts: 6
cjamps is on a distinguished road
Default Passing a variable to a form

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
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


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


All times are GMT -8. The time now is 02:46 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.