473,396 Members | 1,773 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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
where:
nnnn = customer id
x = account size
S = Savings account type

example:

• 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
  2.  
  3. Private Sub btnAccountSave_Click()
  4.  Dim strQuery As String
  5.  
  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
  14.  
  15. End Sub
  16.  
  17. '><
  18.  
  19. Private Sub txtAccountCustomerId_AfterUpdate()
  20. Dim strQuery As String
  21.  
  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
  32.  
  33.  
  34.      End If
  35. End Sub
Sep 16 '12 #1
1 1588
zmbd
5,501 Expert Mod 4TB
Rheigny
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).

-z
Sep 16 '12 #2

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

Similar topics

1
by: vic | last post by:
Hello, Dean Try this: select distinct c1, c2 into #tmp_1 from t1 select count(*) as cnt from #tmp_1 drop table #tmp_1 With best regards.
0
by: DataFreakFromUtah | last post by:
Hello! No question here, just a procedure for the archive. Search critera: count records imported count data imported count number of rows imported count number of records imported record import...
1
by: tranky | last post by:
hi, only one information,please... how to count number of anonymous online users? I use ASP.NET 2.0 thank u tranky
5
by: isabelle | last post by:
hi, every body.. I have two program I couldn’t solve them So, can any body help me. please!! 1-Write a program that accepts a character and count number of occurrences in a file. The file...
11
by: Mack | last post by:
Hi all, I want to write a program to count number of bits set in a number. The condition is we should not loop through each bit to find whether its set or not. Thanks in advance, -Mukesh
6
by: vbwire | last post by:
i use vb 6.0 Option Explicit Dim Error As Double Dim x As Integer Dim y As Double Dim z As Integer
2
by: mfaisalwarraich | last post by:
Hi Everybody, I am using the following code to get the recordset of an external database. Dim dbPatients As Database Dim rsCountPatients As Recordset ' to count number of...
5
by: jambonjamasb | last post by:
I am wanting to create a report that summarises the number of items within a date range. For example I have a FIELD called System_Change. This is a drop down COMBOBOX that uses words like unix,...
1
by: jlt206 | last post by:
This code <?php include("counter.php")?> on the webpage produces the count number. (function code below) I want to place the current number into a variable $MemberNo or into a FormField to be sent...
6
by: cathrine babe | last post by:
How To Count Number Of Words In A Sentence
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.