Results 1 to 2 of 2

Thread: Help in Coding a command

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2012
    Posts
    1

    Exclamation Help in Coding a command

    Hello everyone, this is my first post here
    I am making a bank database management system for my Olevel Computer Studies project. I am using VB6 as the front end and MS Access 2003 as the back-end database.
    i am trying to code a command which will take the Ammount entered into a form and edit the customer balance according to it.
    for eg. the bank user clicks on the withdrawals form. there are fields for account number, transaction number, amount withdrawn etc. the bank employee must enter the account number that needs to be accessed , the ammount to be withdrawn and all other feilds like cheque slip number etc.( i am attaching a screenshot of the form) the problem is the coding of the transaction save button.
    i have written the following coding :
    Code:
    Private Sub cmdSave_Click()
        
        Dim AcCode As Object
       Set AcCode = txtAccountNo
            tblCstmrInfo.Refresh
            
      tblCstmrInfo.Recordset.Find ("accountno=" & "'" & AcCode & "'") 'for finding out string file.
         
         If tblCstmrInfo.Recordset.EOF Then
            MsgBox "No Match Found", vbExclamation, "Please enter a registered Code"
            tblCstmrInfo.Refresh
              End If
        
        Dim DAmmount As Object
        Dim InitBalance As Object
              Set DAmmount = (txtDeposit)
              Set InitBalance = (txtBalance)
        Dim FinalBalance As Object
              Set FinalBalance = InitBalance + DAmmount
         Set txtBalance = FinalBalance
      
      tblCstmrInfo.Recordset.Update
        tblWithdraw.Recordset.Update
              
       tblWithdraw.Recordset.Update
        MsgBox ("Record has been saved !")
        
     End If
    End Sub
    i have included the error screen too ... please help ...
    Attached Images Attached Images    

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Help in Coding a command

    Set InitBalance = (txtBalance)
    That line (in the presented context) makes no sense. Why are setting new object when all you need is value from textbox?

    Also, why are you setting object when calculating sum?

    Set FinalBalance = InitBalance + DAmmount <<< ???

    Instead, declare FinalBalance variable as (perhaps) Double and calculate sum like this:

    FinalBalance = Val(txtBalance.Text) + Val(txtDeposit.Text)

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