I'm currently working on a small bank account register program for myself (just to help me get aclamated to vissual studios) and I was doing ok until I put in the add new database and add new account pages. I wrote code that takes the blank database copies it and renames it to what the user specifies. The extention is also changed from *.mdb to *.kcm. But when I have the database changed in the script the program does not change the database. The other 2 problems I'm having are probably an over site on my part from being so new at this. But when I try and change the table that I'm looking at the code seems to be right but it does not change. and the last problem is I have a form open that has for a better term the entire table of acounts put into a list box so that you can choose the account that you want to look at. But when a new account is added I can't get the list to update but when you close the database and reopen it the new account shows. Can anyone give me any tips on this and how I can make it work? I am not using ado yet I'm using the data function.

This is the code for the new database:

Private Sub Form_Activate()
'Opens the open common dialog and saves the filename and location to Databaselocation

On Error GoTo 1
cdg_New.CancelError = True
'cdg_Open.InitDir = mstrLastDir
cdg_New.Flags = cdlOFNHideReadOnly
cdg_New.FileName = ""
cdg_New.Filter = "Database Files(*.kcm)|*.kcm|All Files(*.*)|*.*"
cdg_New.ShowOpen
Databaselocation = cdg_New.FileName
FileCopy database2, Databaselocation
frm_Accounts.Show


1
Me.Hide
End Sub

This is the code for the list box form:

Private Sub Form_Activate()
On Error GoTo 911
Me.Refresh

data_Acts.DatabaseName = Databaselocation 'sets the database to the database the user selected





data_Acts.Recordset.MoveFirst
lst_Acts.Clear

'Sets the items in the list box to that of the table in the database

Do Until txt_BankName.Text = ""
lst_Acts.AddItem (txt_BankName.Text & "     " & txt_ActType.Text & "     " & txt_ActNum.Text & "     " & txt_Bal.Text)
data_Acts.Recordset.MoveNext
Loop

911
Resume Next
End Sub

Private Sub Form_GotFocus()
On Error GoTo 911
data_Acts.DatabaseName = Databaselocation
data_Acts.Recordset.MoveFirst
lst_Acts.Clear

Do Until txt_BankName.Text = ""
lst_Acts.AddItem (txt_BankName.Text & "     " & txt_ActType.Text & "     " & txt_ActNum.Text & "     " & txt_Bal.Text)
data_Acts.Recordset.MoveNext
Loop

911
Resume Next
End Sub

and this is the code for the add new account:

Private Sub cmd_OK_Click()
On Error GoTo 911
' Checks if slots 1-15 are empty
If txt_Act.Text = "" Then
ACTRd = 1
GoTo 1
End If
data_Acts.RecordSource = "actinfo2"
If txt_Act.Text = "" Then
ACTRd = 2
GoTo 1
End If
data_Acts.RecordSource = "actinfo3"
If txt_Act.Text = "" Then
ACTRd = 3
GoTo 1
End If
data_Acts.RecordSource = "actinfo4"
If txt_Act.Text = "" Then
ACTRd = 4
GoTo 1
End If
data_Acts.RecordSource = "actinfo5"
If txt_Act.Text = "" Then
ACTRd = 5
GoTo 1
End If
data_Acts.RecordSource = "actinfo6"
If txt_Act.Text = "" Then
ACTRd = 6
GoTo 1
End If
data_Acts.RecordSource = "actinfo7"
If txt_Act.Text = "" Then
ACTRd = 7
GoTo 1
End If
data_Acts.RecordSource = "actinfo8"
If txt_Act.Text = "" Then
ACTRd = 8
GoTo 1
End If
data_Acts.RecordSource = "actinfo9"
If txt_Act.Text = "" Then
ACTRd = 9
GoTo 1
End If
data_Acts.RecordSource = "actinfo10"
If txt_Act.Text = "" Then
ACTRd = 10
GoTo 1
End If
data_Acts.RecordSource = "actinfo11"
If txt_Act.Text = "" Then
ACTRd = 11
GoTo 1
End If
data_Acts.RecordSource = "actinfo12"
If txt_Act.Text = "" Then
ACTRd = 12
GoTo 1
End If
data_Acts.RecordSource = "actinfo13"
If txt_Act.Text = "" Then
ACTRd = 13
GoTo 1
End If
data_Acts.RecordSource = "actinfo14"
If txt_Act.Text = "" Then
ACTRd = 14
GoTo 1
End If
data_Acts.RecordSource = "actinfo15"
If txt_Act.Text = "" Then
ACTRd = 15
GoTo 1
Else: GoTo 9111
End If


1
' After a blank record source is found the information is entered
a = ACTRd
BName(a) = txt_BankName.Text
ActT(a) = com_ActTy.Text
ACTN(a) = txt_AccountNumber.Text
STB(a) = txt_StartBal.Text
data_Bankact.Recordset.MoveLast
data_Bankact.Recordset.AddNew
txt_BName.Text = BName(a)
txt_AcountType.Text = ActT(a)
txt_AccountNumber.Text = ACTN(a)
txt_Owner = UserName
txt_Ctable.Text = a
txt_StartingBal.Text = STB(a)
data_Bankact.Recordset.Update
MsgBox ("New Account Added")




Me.Hide
Exit Sub



911
Resume Next

9111
MsgBox (Error03)
Me.Hide
End Sub

Private Sub Form_Activate()
data_Acts.DatabaseName = Databaselocation
data_Bankact.DatabaseName = Databaselocation
txt_BankName.Text = ""
com_ActTy.Text = ""
txt_AccountNumber.Text = ""
txt_StartBal.Text = ""

End Sub

Private Sub Form_Load()
com_ActTy.AddItem "Checking"
com_ActTy.AddItem "Saving"
com_ActTy.AddItem "Cd"
com_ActTy.AddItem "EBT Debit"
com_ActTy.AddItem "EBT Food Stamps"
com_ActTy.AddItem "Credit Card"
com_ActTy.AddItem "401k"

End Sub

I can provide any other info needed to help figure out the problems I am having.
Thank you so much for taking the time to help me

Recommended Answers

All 2 Replies

But when a new account is added I can't get the list to update but when you close the database and reopen it the new account shows

This is the easy part, just run the population code of the listbox AFTER the new record was added.

I'm not sure what you are trying with the first part though. Why change the access (mdb) database to something else (kcm)?

Thank you for your response, and the reason I changed the extention is so that it is harder for an unathorized user to figure out that the file can be opened with access. I know it's silly but I'm just using it as a learning tool.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.