Talk About Network

Google





Software > Access Forms > RE: number incr...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 7 Topic 46512 of 46786
Post > Topic >>

RE: number increment depending on a combo box entry

by =?Utf-8?B?RGFsZSBGeWU=?= <dale.fye@[EMAIL PROTECTED] > Dec 3, 2008 at 10:46 AM

Well,

If you need a field that increments like this, then I would recommend that

you store this data in three fields (ClientID, ClientStatus, and
ClientNum).  
I would make ClientID as an Autonumber, and would not expose it to your
users 
at any time.  This would be the value that you place in other tables as a 
foreign key.

Then, to fill in ClientNum, I would use something like the following, in
the 
BeforeUpdate event of a form.

Public Sub Form_BeforeUpdate

 Dim strCriteria as string

  if me.newrecord then
    strCriteria = "[ClientStatus] = '" & me.cboClientStatus & "'"
    me.txtClientNum = NZ(DMAX("ClientNum", "yourTableName", strCriteria),
0) 
+ 1
  endif

End Sub

This way, right before you write the record, this code would determine the

ClientNum value.  If you do it any earlier than this, then the chance
exists, 
if you have a multi-user application, that someone else will be quicker
than 
you, and will inadvertently generate the same number.
  
Then, in your later forms, you can just display the clientStatus and 
ClientNum concatenated together, but use the ClientID field as your PK.
-- 
HTH
Dale

email address is invalid
Please reply to newsgroup only.



"punitha" wrote:

> hi,
> 
> i am new to access. currently, i'm working with multiple tables and
forms.
> 
> in one form,
> i have text field: txtClientID; Data type: Text, which i use as primary
key 
> to number my entries; input mask "L000".
> i also have a combo box, cboClientStatus, which identifies the 
> status/category of my clients, e.g. Hospital, Clinic and Other.
> 
> now, i need ur help to set the primary key to increase by 1 depending on
the 
> status/category of my clients, like:
> H001, H002, H003, ... (for Hospitals)
> C001, 002, C003, ... (for Clinics)
> O001, O002, O003, ... (for all other than Hospitals and Clinics)
> 
> i want the number to increase automatically when i choose the status of
my 
> clients. i know i need a vb for this, probably at cboClientStatus in
After 
> Update event. can u guys pls help me with this.
> 
> thanx a bunch.
 




 7 Posts in Topic:
number increment depending on a combo box entry
=?Utf-8?B?cHVuaXRoYQ==?=   2008-12-02 23:04:01 
RE: number increment depending on a combo box entry
=?Utf-8?B?RGFsZSBGeWU=?=   2008-12-03 10:46:11 
RE: number increment depending on a combo box entry
=?Utf-8?B?cHVuaXRoYQ==?=   2008-12-03 20:33:01 
RE: number increment depending on a combo box entry
=?Utf-8?B?RGFsZSBGeWU=?=   2008-12-04 06:24:01 
RE: number increment depending on a combo box entry
=?Utf-8?B?cHVuaXRoYQ==?=   2008-12-09 21:42:01 
RE: number increment depending on a combo box entry
=?Utf-8?B?cHVuaXRoYQ==?=   2008-12-11 01:59:00 
RE: number increment depending on a combo box entry
=?Utf-8?B?cHVuaXRoYQ==?=   2008-12-16 18:12:00 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
localhost-V2008-12-19 Fri Jan 9 14:30:49 PST 2009.