MdotButler
Programmer
I have a data entry form which has a batch header and a sub form with the batch detail records. This form has been used for years and has a bunch of code behind each textbox in the textbox_afterupdate methods to calculate values on the forms, get default values from the database...
The company now gets this information from a third party in a CSV file. They want to import this into the batch header/detail tables as though they were data entered. My first option would be to copy all the logic from the form and put it into an new stand alone import module. My second option would be to use the existing form and simulate data entry if possible by doing an add record, populating the fields one by one, simulate a tab off the field...
I would rather use the second option if possible so I do not have duplicate code in both the data entry form and the import module. My question is how to simulate the data entry. Do I just:
Assuming the above is at least on the right track:
1 - How do I simulate the "Add" button (batch header record) being pressed?
2 - If I am populating the field correctly above, how do I fire the "ContractorNo_AfterUpdate" method?
3 - How do I address the sub form "Add" button (detail records) and fields?
As you can tell my Access VBA is weak. Can this be done in Access 2010 VBA? I have done this in other databases and languages so I am hoping it can be done here. Any guidance would be appreciated.
The company now gets this information from a third party in a CSV file. They want to import this into the batch header/detail tables as though they were data entered. My first option would be to copy all the logic from the form and put it into an new stand alone import module. My second option would be to use the existing form and simulate data entry if possible by doing an add record, populating the fields one by one, simulate a tab off the field...
I would rather use the second option if possible so I do not have duplicate code in both the data entry form and the import module. My question is how to simulate the data entry. Do I just:
Code:
DoCmd.OpenForm DataEntry
Form!DataEntry.ContractorNo.Value = "xxx"
1 - How do I simulate the "Add" button (batch header record) being pressed?
2 - If I am populating the field correctly above, how do I fire the "ContractorNo_AfterUpdate" method?
3 - How do I address the sub form "Add" button (detail records) and fields?
As you can tell my Access VBA is weak. Can this be done in Access 2010 VBA? I have done this in other databases and languages so I am hoping it can be done here. Any guidance would be appreciated.