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


when editing a record it doesnt save

Posted on 2006-04-25
Medium Priority
Last Modified: 2010-05-18
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)
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
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
    '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
End Sub
Question by:aplelois
  • 2
LVL 12

Accepted Solution

Bob Lamberson earned 1200 total points
ID: 16540531

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.

LVL 19

Assisted Solution

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:

Author Comment

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

Expert Comment

by:Bob Lamberson
ID: 16541211
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.


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