Fire actions on a form

  • Thread starter Thread starter Tharnack
  • Start date Start date
T

Tharnack

Hi,
I am asked to make somes changes on an existing Access database and i
know my sql but not very much access.
There is a form for billing clients. On that form there is

-a drop down menu that contains clients who were not billed
-a button that fire the action of printing the bill (+4-5 sql updates in
a couple of tables).
-other stuff

Actually, the user has to manually select each client and press the
print button to get his bill. I need to make this operation "batchable",
ie by pressing a button, all the bills would be printed.
I was thinking about simulating user input to select one by one the
values in the drop down menu and then press the print button.

Does someone can help me on how to do that? Thanks
 
Tharnack said:
Hi,
I am asked to make somes changes on an existing Access database and i
know my sql but not very much access.
There is a form for billing clients. On that form there is

-a drop down menu that contains clients who were not billed
-a button that fire the action of printing the bill (+4-5 sql updates in
a couple of tables).
-other stuff

Actually, the user has to manually select each client and press the
print button to get his bill. I need to make this operation "batchable",
ie by pressing a button, all the bills would be printed.
I was thinking about simulating user input to select one by one the
values in the drop down menu and then press the print button.

Does someone can help me on how to do that? Thanks

I have found a tutorial with lots of content for VB beginners and it was
quite what i was looking for.
Here is what i was able to code:

Private Sub Commande121_Click()

On Error GoTo GererErreur

Dim MyData As DAO.Recordset
Dim MyDB As DAO.Database
Set MyDB = CurrentDb
Set MyData = MyDB.OpenRecordset("select ...")
With MyData
If (.RecordCount > 0) Then

' Enlève le mode aperçu
Me.Visual = False

' Message de confirmation avant de procéder
mess = "Cette opération peut être longue à exécuter." _
& " Voulez-vous vraiment imprimer toutes les factures restantes?"
r = MsgBox(mess, vbCritical + vbYesNo + vbDefaultButton2, "Factures
Restantes")

If r = 6 Then

.MoveFirst
Do Until .EOF
ref_client = MyData("RefClient")
If (ref_client <> "0") Then


' Simule l'entrée du no du client dans le combo box
VNoClient.Value = ref_client
VNoClient_AfterUpdate

'Simule le click du bouton imprimer
ImprimFacture_Click

End If
.MoveNext
Loop
.Close

End If
End If
End With
Set MyData = Nothing
Set MyDB = Nothing
VNoClient.Value = ""

Exit Sub

GererErreur:
MsgBox "Erreur: " & err.Description
Set MyData = Nothing
Set MyDB = Nothing
VNoClient.Value = ""
End Sub



I don't have many time to do intensive debugging but it seems to work
just as expected.

........
 
Back
Top