VB code

G

Guest

Dear Sirs
I have a Macro running perfect and it is executing the following:

- billyearlyhelpappendquery
- billhalfyearhelpappendquery
- billsappendquery
- openbillsappendquery
- Print report – billingcemetery
- billingtabledeletequeryquery

I would prefer to do this in VB. I did the following without success:

Private Sub cmdPrintbill_Click()
Dim stDocName As String

stDocName = “billyearlyhelpappendqueryâ€
stDocName = “billhalfyearhelpappendqueryâ€
stDocName = “billsappendqueryâ€
stDocName = “openbillsappendqueryâ€
DoCmd.OpenReport “billingcemeteryâ€, acViewNormal
stDocName = “billingtabledeletequeryqueryâ€

End Sub

I do not get any error message neither is anything shown if I Debug-Compile.
Can anyone alter my VB code so that it is working?
Thanks
Klaus
 
R

Rick Brandt

Amateur said:
Dear Sirs
I have a Macro running perfect and it is executing the following:

- billyearlyhelpappendquery
- billhalfyearhelpappendquery
- billsappendquery
- openbillsappendquery
- Print report - billingcemetery
- billingtabledeletequeryquery

I would prefer to do this in VB. I did the following without success:

Private Sub cmdPrintbill_Click()
Dim stDocName As String

stDocName = "billyearlyhelpappendquery"
stDocName = "billhalfyearhelpappendquery"
stDocName = "billsappendquery"
stDocName = "openbillsappendquery"
DoCmd.OpenReport "billingcemetery", acViewNormal
stDocName = "billingtabledeletequeryquery"

End Sub

I do not get any error message neither is anything shown if I
Debug-Compile. Can anyone alter my VB code so that it is working?
Thanks
Klaus

You are merely assigning the name of a query to a variable. You are doing
nothing to make them run. Try the following...

CurrentDB.Execute "billyearlyhelpappendquery", dbFailOnError
CurrentDB.Execute "billhalfyearhelpappendquery", dbFailOnError
CurrentDB.Execute "billsappendquery", dbFailOnError
CurrentDB.Execute "openbillsappendquery", dbFailOnError
DoCmd.OpenReport "billingcemetery", acViewNormal
CurrentDB.Execute "billingtabledeletequeryquery", dbFailOnError
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

checkboxes unchecking in VB code 4
opening a form 2
SQL Commands 3
Previewing a report 7
Form question (continuation) 12
Append Queries, table, sql command 4
VB command 2
Please urgent help needed: VB problem 2

Top