Vladimir, here's a couple of sub's that should help you
to get started. Don't forget to add the DAO references.
You can use an SQL Query to search for a particular field
based on the criteria you give it. If you want this information
accessible to all forms within the project, then look to changing
the following code (Add it to a Standard Module (.BAS)) file
as public.
Good Luck.
Chris Val
========
Option Explicit
Dim RecCounter As Long
Dim db As DAO.Database, rst As Recordset
'-----------------------------------------------------------------------------------
Private Sub ExecuteQuery()
'
Set db = OpenDatabase("PathToYourDatabase.mdb")
Set rst = db.OpenRecordset("SELECT * FROM YourTable WHERE FieldName = 'Something'")
'
Do While Not rst.EOF
'
' Add a combo box box to test it out...
Combo1.AddItem IIf(IsNull(rst!FieldName), "", rst!FieldName)
'
rst.MoveNext
'
Loop
'
End Sub
'-----------------------------------------------------------------------------------
Private Sub WriteToDatabase()
'
Set db = OpenDatabase("PathToYourDatabase.mdb", , False)
'
db.Execute "INSERT INTO YourTable (FieldName) VALUES ('NewData')"
'
End Sub
'-----------------------------------------------------------------------------------
| I'm just studying VB, and i have project where I have to create program to
| access Aceess97
| database. I'm using VB5 and Access97 and DAO method to assess database. I
| have 4 general
| 1 main form with tab controls on it, and by clicking tab button certain form
| would open. I
| also have search form, where user will look for the particular record, and
| all data
| associated with this record must be open in all 4 forms. Ex, RefNo 5, and
| all data for this
| client with RefNo5 must appear in all forms.
| Please, can anyone suggest and if possible show how I can use code to search
| for a
| particular record and then show data associated with this record in all
| forms.
| Any comments will be appreciated.
| Thanks in advance
| Vlad
|
|