![]() |
| ||
| vb6/common dialog/access db I am undertaking a project but am hopelessly stuck. :cry: I have trawled the net, read books and followed tutorials but I just can't move forward. I would be really grateful if someone could help. I need to create a sequential name and address file with the following options: open a new file open an existing file add name and address info to open file close a file exit the program. There are defined guidelines that I have so far stuck to. What I think I need to do is change my coding so I have an embedded db template that I can use to create a new db or open an existing db. My code is as follows- Dim TextFileNum As IntegerTy for looking. |
| ||
| Re: vb6/common dialog/access db What are you doing with the access database? It looks like to me, in your code, that you are mixing access databases with sequential files. Which do you want to use, an access database, or sequential files? You do this for access: Set db = OpenDatabase(CMDialog1.FileName) and then this: OpenFileName = CMDialog1.FileName What is your ultimate goal? I can help you, but I need to know exactly what you are trying to accomplish. |
| ||
| Re: vb6/common dialog/access db ok ty your help is really appreciated as this is driving me nuts and taking up so much of my spare time. This is a project I am working through for an evening class (but we are allowed to get help from any source). The wording says a sequential name and address file, but the college I thought hinted that we needed a db to hold the name, address line 1, address line 2, address line 3 and postcode. We have been given various things that we have to put in our coding (including common dialog box) - hence most of what I have included. Being a novice I am finding it so hard to make sense of the examples I am finding in books and on line. My idea is that when I select file new it should allow me to open a new file (that I give a file name to) which is automatically linked to my textboxes. I then think that if I select file open I should be able to open any of my previously created files. I have run into horrendous problems here and have had no luck even though I have tackled it in 3 or 4 different ways. Any help would be great. |
| ||
| Re: vb6/common dialog/access db I'd like to read the requirements. It sounds to me like you could use 1 file for each person that is a record. So, there is a file for rob smith, who lives at 2200 se ave florida.... and another file for robin smithers, who lives at 0022 nw blvd, michigan.... let me see the specifics, and I'll help you out. |
| ||
| Re: vb6/common dialog/access db Ok so as I said earlier I need to create a sequential name and address file with the following options: open a new file open an existing file add name and address info to open file close a file exit the program. My form has a drop down menu with file new, open, close and exit options. It has 5 textboxes - Name, Address1, Address2, Address3, Postcode and an add command button. It also has a common dialog control. So it then goes on to say code form_load set the string variable OpenFileName to empty code mnuNew_click set file filters for all files or txt files in the common dialog set FilterIndex to default to all files display open file dialog assign FreeFile number to the variable TextFileNum open selected file as output set OpenFileName variable to the common dialog FileName code mnuOpen_click set file filters for all files or txt files in the common dialog set FilterIndex to default to all files display open file dialog assign FreeFile number to the variable TextFileNum open selected file as append set OpenFileName variable to the common dialog FileName code mnuClose_click if a file is open close file set string variable OpenFileName to empty code mnuExit_click if a file is open close it end the program code mnuAdd_click write the data in the textboxes to the file clear the data from the textboxes There are some basic things I have left out such as message boxes and enabled properties etc - these are in the code already. Hope this makes sense. Thanks |
| ||
| Re: vb6/common dialog/access db Can anyone help? As you can see by my coding I have done (I hope) the majority and am just stuck on how to put the information into a db or sequential file. Am running out of time and ideas fast. Thanks |
| ||
| Re: vb6/common dialog/access db 1 Attachment(s) This has been fully commented. I would advise you to change some of the things in it, so that it fits the technique you are using, but, this should be a working copy of what you have been working on. |
| ||
| Re: vb6/common dialog/access db Thank you so much for your help so far. Just one question (for now anyway!) is there a way that when i open a file I have already created it can show the data stored in the correct textboxes. I have tried playing around with the code but I can't seem to hit upon the correct terminology to make it work. Ty |
| ||
| Re: vb6/common dialog/access db Help me please somebody - I am in danger of taking a screwdriver to my laptop!! This code kind of works in the mnuOpen Dim TempStr As String ' Temporary Variable Open OpenFileName For Input As #TextFileNum ' .. open the file Do While Not EOF(1) ' While still records in file .. Line Input #1, TempStr ' Read a line into the variable txtName.Text = txtName.Text & TempStr & vbCrLf ' Display it in Text1 Loop Close #1 ' All done: close the file However 2 problems - my specification says open file as append and this only works if I open file for input. Also it lumps all of the inputted data together and displays it all in the one text box. Adding all of the text boxes just means all of the data is shown in all of the text boxes. Dim TempStr As String ' Temporary Variable Open OpenFileName For Input As #TextFileNum ' .. open the file Do While Not EOF(1) ' While still records in file .. Line Input #1, TempStr ' Read a line into the variable txtName.Text = txtName.Text & TempStr & vbCrLf ' Display it in Text1 txtAddress1.Text = txtAddress1.Text & TempStr & vbCrLf txtAddress2.Text = txtAddress2.Text & TempStr & vbCrLf txtAddress3.Text = txtAddress3.Text & TempStr & vbCrLf txtPostCode.Text = txtPostCode.Text & TempStr & vbCrLf Loop Close #1 ' All done: close the file Thanks |
| All times are GMT -4. The time now is 4:42 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC