Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reference SQL Tables with VB in .adp

Status
Not open for further replies.

lamago

MIS
Sep 13, 2004
27
US
Hi everyone,

I finished putting all of my access tables into SQL Server 2000, i have all my procedures set, now I want to make an .adp front end, because im told this will allow multiple users into one database without corrupting the file, which has happened several times already. users will be accessing it through the network.

Okay MY QUESTION: My forms use Dmax to pull the value from a field Update in the table ClassSchedule, then set a label to show that date. Now how to I do this in .adp? How do I reference the table? How can I get a label to show the value in a given field for a table in the access project?
 
In a standard module setup some code in a public function. You can use the currentproject.connection since that is already connected to the server.

in textbox put =ReturnOrderID()

Public Function ReturnOrderID() As Date
Dim cn As New ADODB.Connection, sql1 As String
Dim rs As New ADODB.Recordset

Set cn = CurrentProject.Connection

sql1 = "select max(yourdate) as adate from ClassSchedule"
''Debug.Print sql1
rs.Open sql1, cn, adOpenStatic, adLockOptimistic

If Not (rs.EOF And rs.BOF) Then
ReturnOrderID = rs!adate
Else
MsgBox "No Date returned"
End If
rs.Close
Set rs = Nothing
Set cn = Nothing

End Function

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top