|
 |
access thread: Getting Data from form. Placing into another form DAO
Message #1 by "Christopher Mohr" <cmohr@b...> on Thu, 31 Jan 2002 19:25:58
|
|
I have tried the following code to place data into a new form, but it does
not seem to work. There are no errors, but my new form does not display
the old forms contents.
Private Sub Form_Open(Cancel As Integer)
Dim db As DAO.Database
Dim rsCompany As DAO.Recordset
Dim intNumber As Integer
Set rsCompany = db.OpenRecordset _
("SELECT CompanyID, ContactID, ContactName FROM Contacts" & _
" WHERE CompanyID = " & _
Chr$(34) & Forms!Company!CompanyName & Chr$(34) & _
" ORDER BY ContactName ASC", _
dbOpenDynaset)
End sub
And I have tried this.
Dim db As DAO.Database
Dim rsCompany As DAO.Recordset
Dim intNumber As Integer
Dim strSQL as string
strSQL="SELECT CompanyID, ContactID, ContactName " & _
"FROM Contacts " & _
"WHERE CompanyID = Forms!Company!CompanyName " & _
"ORDER BY ContactName"
Set rsCompany = db.OpenRecordset(strSQL, dbOpenDynaset)
Neither have worked.
Chris
Message #2 by "John Ruff" <papparuff@c...> on Thu, 31 Jan 2002 11:39:53 -0800
|
|
You need to take the SQL statement and place it in the RecordSource
property of the new form;
"SELECT CompanyID, ContactID, ContactName FROM Contacts WHERE CompanyID
= Forms!Company!CompanyName ORDER BY ContactName"
The old form must be open for this to work.
John Ruff - The Eternal Optimist :-)
Available for Contract Opportunities
John Ruff
9306 Farwest Dr SW
Lakewood, WA 98498
xxx-xxx-xxxx
papparuff@c...
-----Original Message-----
From: Christopher Mohr [mailto:cmohr@b...]
Sent: Thursday, January 31, 2002 7:26 PM
To: Access
Subject: [access] Getting Data from form. Placing into another form DAO
I have tried the following code to place data into a new form, but it
does
not seem to work. There are no errors, but my new form does not display
the old forms contents.
Private Sub Form_Open(Cancel As Integer)
Dim db As DAO.Database
Dim rsCompany As DAO.Recordset
Dim intNumber As Integer
Set rsCompany = db.OpenRecordset _
("SELECT CompanyID, ContactID, ContactName FROM Contacts" & _
" WHERE CompanyID = " & _
Chr$(34) & Forms!Company!CompanyName & Chr$(34) & _
" ORDER BY ContactName ASC", _
dbOpenDynaset)
End sub
And I have tried this.
Dim db As DAO.Database
Dim rsCompany As DAO.Recordset
Dim intNumber As Integer
Dim strSQL as string
strSQL="SELECT CompanyID, ContactID, ContactName " & _
"FROM Contacts " & _
"WHERE CompanyID = Forms!Company!CompanyName " & _
"ORDER BY ContactName"
Set rsCompany = db.OpenRecordset(strSQL, dbOpenDynaset)
Neither have worked.
Chris
|
|
 |