Click to See Complete Forum and Search --> : Saving User Entered Data


dimspyder
September 18th, 2001, 09:05 PM
ok first off i have a form with 3 textbox input areas. the user puts in the name of the script, the information to search for, and the response. they then hit the "add script" command button and it displays the name of the script (which they just specified) in a listbox. This also saves the information and response with it. the problem i have is that if the user closes that form then all the data is lost from it. i need some way to save the data they have entered to make it available for them later so they do not have to keep re-entering all the data fields. I am guessing that i need to keep a database file or a .ini of some sort, im not exactly sure. another thing which would be nice is when the user clicks on the script name in the listbox it displays the information in the 3 textbox fields that the user entered to make that script. im also not sure where to begin with that, i assume it also needs some sort of database. i think this just entails figuring out how to save input from a user after a form is closed, so it reappears when they open it again. if anyone can help on those 2 problems, that would be wonderful. i have been asking a few people on some programming channels (irc) and none of them have been able to help so far. thanks for taking the time to read this and possibly offer a solution or suggestion.

-frank

dimspyder
September 18th, 2001, 10:08 PM
ok i just figured out a cheap way of saving the data when they close the form (which isnt the main form), by just hiding it when they close, instead of unloading. i still need to save the data to a database for when they close the program completely to still save the entered data if anyone can help with that. thx,

-frank

Cakkie
September 19th, 2001, 01:19 AM
Here's what we will do, create a database in Access (or with the datadesigner), add a table called "Scripts", which has 3 columns (i will call them Column1, Column2 and Column3). Place the database is the same folder as the project. Add a ADO Control (ActiveX Data Objects control) to the form, you probably need to add it via the project>components menu.

' general declaration section
private cnn as ADODB.Connection
private rst as ADODB.Connection

private Sub Form_Load()

' open connection to database
set cnn = new ADODB.Connection
cnn.provider = "Microsoft.Jet.OLEDB.4.0"
cnn.open App.Path & "\scripts.mdb"

' open the recordset
set rst = new ADODB.Recordset
rst.Open "SELECT * FROM dbo_tblWerknemers", cnn, adOpenKeyset, adLockOptimistic

' bind the fields to the data control
set Text1.DataSource = Adodc1
set Text2.DataSource = Adodc1
set Text3.DataSource = Adodc1

' vind the fields to a specific field
Text1.DataField = "Column1"
Text2.DataField = "Column2"
Text3.DataField = "Column3"

' finally, attch recordset to control
set Adodc1.Recordset = rst

End Sub



What this code does is it opens a recordset, and binds it to the form. This way, you don't need to do the saving and loading stuff yourself. You can see that by pressing the datacontrol, you cannavigate through the recordset, without any code.

Tom Cannaerts
slisse@planetinternet.be

Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook

dimspyder
September 19th, 2001, 01:32 AM
thanks, i will have to install Access tomorrow and will try out your suggestion, looks like it should work for what i need. Thanks a bunch for the info :)

(will post tomorrow sometime letting you know if it works out as it should)

-frank

Cakkie
September 19th, 2001, 01:36 AM
The Visual Datamanager is supplied with VB, which can also be used to create the database, this doesn't require you to install Access. It can be found in the Add-ins Menu.

Tom Cannaerts
slisse@planetinternet.be

Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook

dimspyder
September 19th, 2001, 01:50 AM
ok I found the DataManager, but I dont understand how that works. I am more familiar with Access. I don't even see a place to add tables using the DM, lol. I've never even seen that before. Oh well, I will just try it with Access, I think that it will work once I install and make the .mdb. thanks for the help,

-frank