469,071 Members | 1,970 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,071 developers. It's quick & easy.

Count the number of CustomerAccounts by looping

hi I'm new in Ms access/vba and im creating a banking system for my school project.I have a form which is AddAccountView i want the user to enter their CustomerId and i will check if that is exist in my CustomerTable (to add their account they need to fill up in AddCustomerView form) now i let them choose their accountType if savings or timedeposit and i will give their account number in this format
Savings and timeDeposit Account number must follow this String pattern: nnnnxS
nnnn = customer id
x = account size
S = Savings account type


• 10011S = 1st account of customer 1001, type is Savings
• 10012S = 2nd account of customer 1001, type is Savings
• 10013T = 3RD account of customer 1001, type is TimeDeposit
• 10099S = 9th account of customer 1009, type is Savings
• 101015S = 15th account of customer 1010, type is Savings

so account size will count as long as the customerId is creating new account.. my problem is how will i loop the accountsize specifically for the given CustomerId and throw it in my table "TblAccount" the method of looping is still not there cause i dont know where to start.. i hope you can help me..
tnx! =)
this is my codes:

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  3. Private Sub btnAccountSave_Click()
  4.  Dim strQuery As String
  6.  If cmbAccountType.Value = "Savings Account" Then
  7.     txtAccountNumber.Value = _
  8.    (txtAccountCustomerId.Value & " " & "S")
  9.   ElseIf cmbAccountType.Value = _
  10.     "TimeDeposit Account" Then
  11.        txtAccountNumber.Value = _
  12.       (txtAccountCustomerId.Value & " " & "T")
  13.  End If
  15. End Sub
  17. '><
  19. Private Sub txtAccountCustomerId_AfterUpdate()
  20. Dim strQuery As String
  22.  If IsNull(DLookup("CustomerId", "TblCustomer", "CustomerID = " & [txtAccountCustomerId] & " ")) Then
  23.         MsgBox "Customer Id doesn't exist!"
  24.         txtAccountNumber.Enabled = False
  25.         txtInitialDeposit.Enabled = False
  26.         txtMaintainingBalance.Enabled = False
  27.     Else
  28.         cmbAccountType.Enabled = True
  29.         txtAccountNumber.Enabled = False
  30.         txtInitialDeposit.Enabled = False
  31.         txtMaintainingBalance.Enabled = False
  34.      End If
  35. End Sub
Sep 16 '12 #1
1 1516
5,400 Expert Mod 4TB
Please understand we do not answer homework questions.

You should be able to do this without VBA using a few queries.

As for the design of your form and the underlying code... currently, with what little you've given, there are 4 ways I can think of to solve your issue. Temp tables, array, temp variables, global variables, and class type (ok... 5.... well 6 counting the queries).

Sep 16 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by vic | last post: by
1 post views Thread by tranky | last post: by
11 posts views Thread by Mack | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.