Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

when editing a record it doesnt save

Posted on 2006-04-25
4
Medium Priority
?
186 Views
Last Modified: 2010-05-18
hello,
I have a button in main.frm called edit with this

Private Sub cmdEdit_Click()
On Error Resume Next
Enabled = False
Load frmAccountDetails
frmAccountDetails.Populate (lstAccounts.ListIndex)
frmAccountDetails.Show
End Sub

and this in details.frm
Private Sub cmdOK_Click()
Dim FileNo As Integer
On Error Resume Next

FileNo = FreeFile
Open "Accounts.ini" For Append Shared As #FileNo
Print #FileNo, Text_Email.Text & ";" & Text_Passwd.Text & ";"
Close #FileNo

frmMain.Enabled = True
frmMain.SetFocus
Unload frmAccountDetails
End Sub

Public Sub Populate(ByVal Record As Long)
'On Error Resume Next
    Dim lngFHandle As Long
    Dim strLine As String
    lngFHandle = FreeFile()
    Open "Accounts.ini" For Input As #lngFHandle
    Dim intRecord As Long
    For intRecord = 0 To Record
       Line Input #lngFHandle, strLine
    Next
    'That has gone through the file till we have the correct record
    Text_Email = Split(strLine, ";")(0)
    Text_Passwd = Split(strLine, ";")(1)
End Sub

but is not saving the edited record!!! why is that?

this is the add button in main.frm that is working fine, but every time I add a record it doesnt show
until I reload the app..

Private Sub cmdAdd_Click()
On Error Resume Next
Enabled = False
frmAccountDetails.Show
End Sub
0
Comment
Question by:aplelois
  • 2
4 Comments
 
LVL 12

Accepted Solution

by:
Bob Lamberson earned 1200 total points
ID: 16540531
aplelois,

Try closing the file after you populate it. Also Write #fileno  instead of Print and see if that makes a difference. Also You might need a path to the Accounts.ini file.

Bob
0
 
LVL 19

Assisted Solution

by:BrianGEFF719
BrianGEFF719 earned 800 total points
ID: 16540784
Perhaps consider using the GetPrivateProfile() API. It provides access to INI files.

See the following article on editing INI files:
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_21596960.html
0
 

Author Comment

by:aplelois
ID: 16540859
ok I just added Close #lngFHandle
at the end of the populate, but now its making a new record!
0
 
LVL 12

Expert Comment

by:Bob Lamberson
ID: 16541211
aplelois,
I guess I was expecting that your call to populate the new record would append a new record and the cmdOK button would be the button to edit any changes to the populated values. At least that's what it appears the code is doing, but of course I have not tested it.

Bob
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question