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!

Connection

Status
Not open for further replies.

rozzay

Programmer
Jan 3, 2002
142
US
Hi I am having some trouble connecting or open my tables from an ACCESS table i set up on my c drive. I keep getting an error that i need to set my object with something or did i reference the wrong library. Please help and thanks in advance.
============================================================
Private Sub Form_Load()
lblDate.Caption = Date
Set rsLogRpt = adoLog.Recordset

End Sub

Private Sub cmdNext_Click()
Dim vbResult As VbMsgBoxResult
If ValidData Then
adoLog.Recordset.Open
If Not adoLog.Recordset.BOF Then
adoLog.Recordset.MoveFirst
End If
adoLog.Recordset.AddNew
strEDPO = txtEDPO.Text
adoLog.Recordset("old_mf") = Trim(strEDPO)
adoLog.Recordset("time") = Date
adoLog.Recordset.Save
adoLog.Recordset.Close
Unload Me
frmTemp.Show
End If
End Sub

Private Function ValidData() As Boolean
Dim strMsg As String

If txtEDPO.Text = "" Then
strMsg = "Please enter EDPO50 data."
txtEDPO.SetFocus
Else
ValidData = True
End If

If ValidData = False Then
MsgBox strMsg, vbOKOnly
End If

End Function
 
How is adoLog defined and where is is initialized?
how is rsLogRpt defined?
Where exactly is the error occurring
Good Luck
------------
Select * from Users where Clue > 0
0 rows returned
 
the error occurs when i try to open the recordset and i have the rsLogRpt defined in the module as:
public rsLogRpt as adodb.recordset

and for the adoLog being defined and initialize i don't think i have done that because b4 I don't I did but I was accessing a sql server instead of microsoft access.

thanks a bunch!
 
I'd change adoLog to ADODB Craig, mailto:sander@cogeco.ca

Remember not to name the Lambs...
It only makes the chops harder to swallow
 
I have the adoLog in the module as :
public adoLog as ADODB.CONNECTION

does that help any??
 
I can only assume that adoLOG is supposed to be your connection object, but no connection has been established with it.

Dim adoLOG As New ADODB.Connection

then establish your connection with the appropriate parameters for your database.

The following is an example of a connection, but you may or may not need everything shown here

With adoLOG
.Provider = "MSDASQL"
.ConnectionString = "ODBC;DSN=;Driver={Microsoft Access Driver (*.mdb)};DBQ=c:\dirname\dbname.mdb;USR=;PWD=;"
.ConnectionTimeout = 30
.Mode = adModeReadWrite
.Open
End With

and of course substitute your pathname for the c:\dirname\dbname.mdb as shown in the example Good Luck
------------
Select * from Users where Clue > 0
0 rows returned
 
It looks like you are trying to use an ADO control to traverse through your data. I would recommend dumping the control and just using the ADO's connection and recordset objects.

Dim oCon as New ADODB.Connection
Dim oRs as New ADODB.Recordset

Then code your load event to open the connection and the public recordset. Code your next/back buttons to just use the MoveNext and MovePrevious methods. Also add an Add New button to do the adding of records in whatever table you are connecting to.

Good Luck,
-Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top