General discussion

Locked

Select an Access database from V Basic

By hurdk ·
I am interested in using Visual Basic to select and open an Access database in a particular directory.

Thank you.

This conversation is currently closed to new comments.

7 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Select an Access database from V Basic

You can use the Common Dialogs control (Add Microsoft Common Dialogs from Project|Components) to locate the file you want to open.
Once you have the file name and path, you can then open it using the method of your choice, e.g. ADO/DAO.

Collapse -

Select an Access database from V Basic

by hurdk In reply to Select an Access database ...

The question was auto-closed by TechRepublic

Collapse -

Select an Access database from V Basic

by JackOfAllTech In reply to Select an Access database ...

Here is some sample code:
Public Const DB_NAME = "\\some_server\vol1\...\access.mdb"

Public g_dbNetW As Database 'main database object
Public g_qdTop10 As QueryDef

Public g_rsTop10 As Recordset

Public g_sQuery As String

*
* *
*
g_sQuery = "SELECT [field1], [field2], ... From [table1] " & _
"Where (" & _
"([table1].[DATE OCCURRED] >= #" & cboMonth.Text & "/01/" & cboYear.Text & "#) AND " & _
"([EPS TICKETS].[DATE OCCURRED] < #" & sDate & "#)"

If cboDept.Text <> "ALL" Then
g_sQuery = g_sQuery & " AND ([table1].[ASGNDEPT] = """ & cboDept.Text & """)"
End If

g_sQuery = g_sQuery & ")"
Set g_dbNetW = OpenDatabase(DB_NAME, , ReadOnly:=True)
Set g_qdTop10 = g_dbNetW.CreateQueryDef("")
g_qdTop10.SQL = g_sQuery
Set g_rsTop10 = g_qdTop10.OpenRecordset()
DoEvents
Sleep 1
g_rsTop10.MoveFirst
sbStatus.SimpleText = "Processing records"
While Not g_rsTop10.EOF
If g_rsTop10![PROBLEM DESCRIPTION] <> vbNull Then
ProcessTicket
End If

g_rsTop10.MoveNext
Wend

g_rsTop10.Close
g_dbNetW.Close


Ralph

Collapse -

Select an Access database from V Basic

by hurdk In reply to Select an Access database ...

The question was auto-closed by TechRepublic

Collapse -

Select an Access database from V Basic

by TimFox2 In reply to Select an Access database ...

Written by Terry Kreft and distributed by Dev Ashish

http://www.mvps.org/access/api/api0002.htm

This is the simplest method to use and it's pretty muh plug and play.

While we're on the subject, you can use the (Ken Getz) FileOpen or FileSave using this one :
http://www.mvps.org/access/api/api0001.htm

Good luck
Tim

Collapse -

Select an Access database from V Basic

by hurdk In reply to Select an Access database ...

The question was auto-closed by TechRepublic

Collapse -

Select an Access database from V Basic

by hurdk In reply to Select an Access database ...

This question was auto closed due to inactivity

Back to Web Development Forum
7 total posts (Page 1 of 1)  

Related Discussions

Related Forums