URGENT!! Help on CurrentProject.connection Error

shirley_kee

New member
Local time
Today, 20:46
Joined
Sep 15, 2006
Messages
6
Please help. My access prompt out this error when i used combo box wizard

Method 'Connection' of object ' _CurrentProject' Failed.

I couldn't use this VBA Command as well

"CurrentProject.Connection".

Does anybody know how to solve this. I've tried reinstalling ms access but the problem still occur.
 

Attachments

Also, show us your code as you may not be using it properly. One other thing, which version of Access are you using?
 
Thankx a lot Rat. Really appreciate it. I've been cracking my brain few hours figuring out what's wrong with it... Am downloading the software and will try it.
 
Dim dsRecordSet As ADODB.Recordset
Dim cmdAuctioneer As ADODB.Command
Dim sSQL As String

Set dsRecordSet = New ADODB.Recordset
Set cmdAuctioneer = New ADODB.Command

On Error Resume Next
dsRecordSet.Open "tblAuctioneers", CurrentProject.Connection, adOpenStatic, adLockOptimistic

If Err.Number <> "" Then
MsgBox "Error " & Err.Description, vbInformation, "Error"
Exit Sub
End If

On Error Resume Next
dsRecordSet.MoveLast
sAucID = dsRecordSet.Fields("Auc_ID")
If sAucID = "" Then
sAucID = "A100001"
Else
sAucID = "A" & Right(sAucID, 6) + 1
End If
Me.txtAucID.Value = sAucID

Set dsRecordSet = New ADODB.Recordset

'Insert Record

sSQL = "Insert into tblAuctioneers values(" & _
"'" & sAucID & "', " & _
"'" & Me.txtAucName.Value & "', " & _
"'" & Me.txtAucCode.Value & "', " & _
"'" & Me.txtAucCode.Value & "'); "

cmdAuctioneer.CommandText = sSQL

cmdAuctioneer.CommandType = adCmdText
cmdAuctioneer.ActiveConnection = CurrentProject.Connection

Set dsRecordSet = cmdAuctioneer.Execute


dsRecordSet.Close

Set cmdAuctioneer = Nothing
Set dsRecordSet = Nothing
Me.cmdSave.Enabled = True

'Clear textbox
Me.txtAucID = ""
Me.txtAucName = ""
Me.txtAucCode = ""


I try to use the following recordset to insert record to the table at first, but it doens't work. so i try the above code to do it
Do you have any idea?? Oh ya. I'm using access 2000



With dsRecordSet
.AddNew
.Fields("Auc_ID") = sAucID
.Fields("Auc_Name") = Me.txtAucName.Value
.Fields("Auc_Code") = Me.txtAucCode.Value
.Update
End With
 

Users who are viewing this thread

Back
Top Bottom