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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cannot Duplicate Record

Status
Not open for further replies.

tj007

IS-IT--Management
Mar 14, 2003
129
US
Hi

I have placed a command button on a form to duplicate a record in an effort reduce typing. When I click on the duplicate button, Access return a Run-time error 3075 and open the Visual Basic editor and highlighting this line of code.

Set qdef = CurrentDb.CreateQueryDef(sQueryName, "Select * from TripBook where route = " & Me.cboRoute)

Here is the complete code. This code is not related to the command button. This is a combo box. Why is the error pointing to this line? The combo box works fine.

Private Sub cboRoute_AfterUpdate()
Dim qdef As querydef
Dim sQueryName As String
sQueryName = "qryRt_1"
Me.RecordSource = ""
DoCmd.DeleteObject A_QUERY, sQueryName
Set qdef = CurrentDb.CreateQueryDef(sQueryName, "Select * from TripBook where route = " & Me.cboRoute)
Me.RecordSource = sQueryName
End Sub
 
Thanks, here is the code for the button.

Private Sub DupRec49_Click()
On Error GoTo Err_DupRec49_Click


DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste Append

Exit_DupRec49_Click:
Exit Sub

Err_DupRec49_Click:
MsgBox Err.Description
Resume Exit_DupRec49_Click

End Sub
 
If route is not a numeric field, you may consider this:
Set qdef = CurrentDb.CreateQueryDef(sQueryName, "Select * from TripBook where route = '" & Me.cboRoute & "'")

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Have you got the form set up as Modal or Popup by any chance?

Ed Metcalfe.

Please do not feed the trolls.....
 
Thanks PHV & Ed2020

The route field is numeric, and Ed2020 the form is not set to Modal or Popup. I removed the combo box and the error went away. I would like to have the combo box because it helps with filtering the data quickly.
 
Are you sure that Me.cboRoute is numeric ?
You can try something like this:
Set qdef = CurrentDb.CreateQueryDef(sQueryName, "Select * from TripBook where route = " & CLng(Me.cboRoute))


Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
PHV

Me.cboRoute is a combo box and it is returning numeric values. I will try your suggestion and get back with the results
 
Ed nothing happens when I add the line you posted
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top