I have an vba access module which when executed, creates some tables, reads excel files into those tables and then runs a bunch of queries and does some other operations. I now want to front end this with a form so that only certain portions of the code are executed based on what options on the form are seleced before a "Run" button is clicked on the form. Below is an example of my existing Module. I am just looking for an example as to how to begin front ending with form.
Code:
Set db = CurrentDb() 'Establish a Connection to the Current Database
On Error Resume Next
DoCmd.RunSQL ("Create TABLE [countPrescriptionPlan]")
DoCmd.RunSQL ("Create TABLE [countMedicalPlan]")
Set tb2 = db.TableDefs("countPrescriptionPlan")
Set tb3 = db.TableDefs("countMedicalPlan")
.......
'Create table Definitions for Prescription Count
countColumnsPres = Array("CountofEmplid", "CountofDepBen", "Emplid", "DepBen")
For Each col In countColumnsPres
' Set field names for prescription Count
Set FieldName = tb2.CreateField(col, dbText, 100)
tb2.Fields.Append FieldName
Next col
'Create table Definitions for Medical Count
countColumnsMedical = Array("CountofEmplid", "CountofDepBen", "Emplid", "DepBen")
For Each col In countColumnsMedical
' Set field names for prescription Count
Set FieldName = tb3.CreateField(col, dbText, 100)
tb3.Fields.Append FieldName
Next col
.......
DoCmd.OpenQuery "selectMedicalPlan", , acReadOnly
DoCmd.OpenQuery "countMedPlan", , acReadOnly
DoCmd.OpenQuery "selectPresPlan", , acReadOnly
DoCmd.OpenQuery "countPresPlan", , acReadOnly
.......
'Insert the data returned from counrPresPlan query into a temp table
insString = "INSERT INTO countMedicalPlan (CountofEmplid,CountofDepBen,Emplid,DepBen)" _
& " Select CountOfEMPLID, CountOFDEPENDENT_BENEF1, EMPLID, DEPENDENT_BENEF" _
& " From countMedPlan"
DoCmd.RunSQL insString
'Insert the data returned from counrPresPlan query into a temp table
insString2 = "INSERT INTO countPrescriptionPlan (CountofEmplid,CountofDepBen,Emplid,DepBen)" _
& " Select CountOfEMPLID, CountOFDEPENDENT_BENEF1, EMPLID, DEPENDENT_BENEF" _
& " From countPresPlan"
..........