A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Tables and Forms.



 
 
Thread Tools Display Modes
  #1  
Old October 5th, 2004, 11:05 AM
Farooq Sheri
external usenet poster
 
Posts: n/a
Default Tables and Forms.

In Access2000 is it possible to refer to a field in a table from a form with
which it is not linked. For example I have tables Tab1 and Tab2 and I have a
form frmMain and its Record Source property is set to Tab1. Can I access a
record from Tab2 onto a textbox on frmMain.

Thanks
  #2  
Old October 5th, 2004, 11:36 AM
Graham R Seach
external usenet poster
 
Posts: n/a
Default

Farooq,

You have a couple of options:

1. Using DLookup()
Me!txtMyTextbox = DLookup("[myfield]", "Tab2", "field1 = 123")

the "field = 123" part means "WHERE field = 123"

2. Using a recordset
Dim db As Database
Dim rs As DAO.Recordset
Dim sSQL As String

Set db = CurentDb
sSQL = "SELECT myfield FROM Tab2 WHERE field = 123"
Set rs = db.OpenRecordset(sSQL, dbOpenSnapshot)
If rs.AbsolutePosition -1 Then
Me!txtMyTextBox = rs!myfield
End If

rs.Close
Set rs = Nothing
Set db = Nothing

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
---------------------------

"Farooq Sheri" wrote in message
...
In Access2000 is it possible to refer to a field in a table from a form

with
which it is not linked. For example I have tables Tab1 and Tab2 and I have

a
form frmMain and its Record Source property is set to Tab1. Can I access a
record from Tab2 onto a textbox on frmMain.

Thanks



 




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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
creating forms with more then three tables Mick New Users 5 August 18th, 2004 06:04 PM
Query-based forms with multiple tables Andrew Parker Using Forms 1 August 18th, 2004 01:49 AM
Tables and Tabular Forms ecc28 Database Design 0 May 24th, 2004 06:54 AM


All times are GMT +1. The time now is 02:27 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.