Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simulate Data Entry into Form During Import

Status
Not open for further replies.

MdotButler

Programmer
Jan 18, 2006
104
US
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:
Code:
DoCmd.OpenForm DataEntry
Form!DataEntry.ContractorNo.Value = "xxx"
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.
 
I would not attempt to use the second method but that's just me. You can run/call the command button code by just calling its click event. The same would be true for calling the ContractorNo_AfterUpdate.

Again, I wouldn't even attempt to kludge this together using the exiting code.

Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top