[VBA] Saving to file and retrieving information from it through a key in the saved data

yuuzaa

New Member
Joined
Jun 21, 2018
Messages
3
I really don't know how to ask this question, but I'll try...

I have a userform that has severl textboxes for a user to input parameters to calculate production output. Everything else is working perfectly so far, except the [Save] function. This is what I need:

When a user clicks the [Save] button, another userform pops up asking for [Machine No] and [Product Code], then these two strings will be joined together to create the key, followed by delimited data storing the parameters. It will look something like this in the saved file:

Code:
M21P0124 227 115.6 94
M33P0376 312 121 188
AK4A344 110 400 76
M47P1215-2 311 66 48

The first string is a combination of [Machine No] and [Product Code], the next three are parameters, delimited by spaces.

Then, the next time the user opens this form and clicks the [Load] button, another form will pop up with a listbox showing two columns: MachineNo|ProductCode. This will show all the records saved so far, and when an entry is clicked, the corresponding parameters will populate the textboxes. Note that [Machine No] and [Product Code] are only used during save and load, they are not needed anywhere else in the form.

Finally, the saved records must be unique. If the user tries to save duplicate information (Machine/Product combo that already exists), the program should be able to trap it, overwriting existing if the user chooses to.

Can someone give me a guideline on how to do this? I've searched around, I know the saved files can be read line by line, but I need to read the file by the first string of each line, followed by delimited data.

I can take care of the interface and all myself, just need to know how I should save/load the data this way.

Thanks for any input.
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
When a user clicks the [Save] button, another userform pops up asking for [Machine No] and [Product Code], then these two strings will be joined together to create the key, followed by delimited data storing the parameters.
I should add that the parameters will be taken from the textboxes in the open form. When saving, the user only needs to input [Machine] and [Product], both of which will serve as the key for later retrieval.

The form:
Code:
Production Calculator
---------------------
Parameter1:_____________
Parameter2:_____________
Parameter3:_____________

Save dialog box:
Code:
Save
----
MC No.:_____________
Product No. _____________

And when [Load] button is clicked:
Code:
Load
----
M21   P0124
M33   P0376
AK4   A344
M47   P1215-2

Hope this better clarifies. Thanks.
 
Upvote 0

Forum statistics

Threads
1,214,875
Messages
6,122,039
Members
449,063
Latest member
ak94

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top