I need some VB help. I have a command button that I want to run 2 append queries and then a delete query, but I can't quite figure out how to get them to run. I am in the cattle business, so that is why I have the heifer and cow lingo! I have the following in the OnClick part of the VB screen:
Private Sub MakeCows_Click()
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim tdf As DAO.TableDef
Dim rst As DAO.Recordset
Dim varitm As Variant
Dim ctl As Control
Set db = CurrentDb()
Set ctl = Me.SelHfrs
Set qdf = db.QueryDefs("qryHeiferToCowAppend")
Set qdf = db.QueryDefs("qryHeiferToCowLocAppend")
Set qdf = db.QueryDefs("qryDeltblHfrCow")
Set tdf = db.TableDefs("tblHfrCow")
Set rst = tdf.OpenRecordset
When I run it, I get:
Run-time error '3061':
Too few parameters. Expected 2.
When I go to Debug it highlights the first qdf.Execute in the code. I know relatively nothing about VB, but I am slowly seeing the need to.
Any help would be appreciated.
This reply may be too basic for you, David, and I apologise in advance if it is. But the code you need to run your queries is provided by macros. Get macros to run each of these queries and then convert the macros to VBA code. Keep the code, of course, because with a little adapting, you can use it/them to run other access tasks.