473,387 Members | 1,495 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,387 software developers and data experts.

need sequential number in field to count the number of visits per client

4
I have a Client form and a Subform. They are linked by Client ID. Each Client can have multiple visits. There is a button on the Subform to Open a Next Record so that a new visit can be recorded. When this new record opens I want the field named Number of visits to +1. I currently have a macro on the button to open the New record. I know that this is very simple for someone out there, but I am stuck.
Jun 5 '17 #1

✓ answered by NeoPa

Hi.

You need to be clearer about what you want. Do you want a new value to be stored somewhere or simply shown on the form?

The former will lead you into problems but the latter is quite easy to do with a TextBox showing :
Expand|Select|Wrap|Line Numbers
  1. =Count([Field])
It's hard to be more specific when you don't share the necessary details, but we can help more when the question is more clear.

7 1112
NeoPa
32,556 Expert Mod 16PB
Hi.

You need to be clearer about what you want. Do you want a new value to be stored somewhere or simply shown on the form?

The former will lead you into problems but the latter is quite easy to do with a TextBox showing :
Expand|Select|Wrap|Line Numbers
  1. =Count([Field])
It's hard to be more specific when you don't share the necessary details, but we can help more when the question is more clear.
Jun 5 '17 #2
tzinda
4
Hi, I need the number to be stored in the Number of Visits field. So I believe that I have to tie it to the Macro on the button Add New Visit. Right now the Macro is just to open a New Record.
Jun 6 '17 #3
PhilOfWalton
1,430 Expert 1GB
As NeoPa says, what you want is quite easy, but unwise. What happens when you delete a record? There will be a break in your numbers. What happens if you have forgotten to to add a visit and the date of that visit precedes the last visit entered for that client? Then the numbers will be out of sequence with the dates.

The normal way of handling this situation is to have the main form for the client, and a continuous subform showing all the visits in date order.

If you really do insist on a visit number, have a look at something like

Expand|Select|Wrap|Line Numbers
  1. DMax("VisitNo", TblVisits", "ClientID = " & ClientID) + 1
  2.  
Phil
Jun 6 '17 #4
tzinda
4
I do have separate forms for the Client with the Visit information as a subform, but since the visit information requires Subforms it cannot be a continuous form. Is there a way for an expression to count how many previous visits there are for a ClientID? /So let's say clientID 10 is in for the 5th time, is there a way to count say how many previous visits using the VisitID (autonumber)for ClientID 10?
Jun 6 '17 #5
PhilOfWalton
1,430 Expert 1GB
The Visits can be a continuous subform if you wish. It's up to you.

The no of visits can be found using a vaguely similar expression to the one in my last post. This assumes you want to display the Total Visits on the main Client form, anf there is a field on this form called "ClientID".

Expand|Select|Wrap|Line Numbers
  1. TotalVisits = DCount("VisitID", "TblVisits", "ClientID = " & ClientID)
  2.  
Phil
Jun 6 '17 #6
tzinda
4
Thanks, this worked for my purposes!! I appreciate the help!!
Jun 6 '17 #7
NeoPa
32,556 Expert Mod 16PB
You may notice the difference between what I suggested and what Phil suggested. Aggregate, and Domain Aggregate, functions are very much not the same. Aggregate functions make use of data already available whereas Domain Aggregate ones (These generally start with a D.) do not.

I would never recommend using Domain Aggregate functions where the Aggregate equivalents are available. In this situation they are, or at least should be.
Jun 6 '17 #8

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

Similar topics

8
by: Tom | last post by:
Please help. I need a quick little scrpit to place on a web page that will count how many days have passed since January 1, 1970. I have ZERO experience writing ANY scripts. Anyone have any...
6
by: simina | last post by:
Hi... I have a form with 4 number fields: phone area, phone number, cell area, cell number. I did a function that checks the "number" issue for all 4 fields in the same time (because the code is...
7
by: GAVO. | last post by:
Hello every one I have a database with a form called "frmOrders" on that for I need to create a sequential number for each city apart from the original autonumber. So the table "tblorders" would...
4
by: viuxrluxvbbc | last post by:
Hi im trying to write a program that will read in numbers and display them in ascending order along with a count of how many times it repeats. i got the numerical order portion done but cant figure...
9
by: Nooby | last post by:
New to Access here. I inherited a db that has the first column as an automatically generated sequential number. I want to bump it up, but for the life of me I can't figure out how to do it. Is...
10
by: Phil Stanton | last post by:
I am trying to count the fields in a queryDef in an external database. If I run this in the actaal database I get Fields.count = 6 correctly Private Sub ObjectName_DblClick(Cancel As Integer) ...
2
by: masker | last post by:
I was on the web trying to find a javascript that would allow me to input a number on my website and have it increase by a given percentage every second. During my search I found the Earth...
4
by: gitimaya | last post by:
hi can someone help me. I have two talbed. In one table (A)a field is having numbers like 111,222,333(field name (data"). In another table I have a field which has abc111222333xxx(B)(field name...
16
by: neelsfer | last post by:
I need to add sequential lap numbers here. If person's first racenumber is added, it shows lapno =1; if same person in same Race and racedate do 2nd lap then lapno must show =2 Mainform is...
15
by: neelsfer | last post by:
What is easiest way to update a 2nd table used for reports in realtime as fields are filled with data The current table is called RacetimingT and the fields are: Racedate = date field...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.