CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2010
    Posts
    2

    Database Problems

    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?

    Code:
    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:
    Code:
    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:

    Code:
     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
    Last edited by kccomputers2000@live.com; January 4th, 2011 at 07:06 PM.

  2. #2
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: Database Problems

    You need to use Code tags when posting code so it retains the formatting. As posted above it is to hard to read.
    Always use [code][/code] tags when posting code.

  3. #3
    Join Date
    Dec 2010
    Posts
    2

    Re: Database Problems

    How do you use the code tags on here? Usualy I've seen an option to start and end the code tag

  4. #4
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: Database Problems

    Just like an HTML tag but with the word code instead of HTML [ code ] [ /code ] without the spaces.
    Always use [code][/code] tags when posting code.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured