Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Concatenation of Fields

Status
Not open for further replies.

akik

IS-IT--Management
Mar 27, 2002
1
US
On my form I want to create a field which will concatenate as follows.

I know how to concatenate but don't know how to create the last calculation.

12357-“Cat”-“DocNo”-“SubDocNo”-[(needs to go to the table and find the greatest value for field (which has a max value for that combination of (Cat and DocNo and SubDocNo)+ 1 and display that value in this field)]

eg. 12357-PRO-10-02-0001

Next time when the button is pressed it should become

12357-PRO-10-02-0002

If User picks Cat = TNO then

12357-TNO-10-02-0001

in the next instance should be

12357-TNO-10-02-0002

User will pick the Cat, DocNo and SubDocNo from a drop down list.

where 12357 is fixed values and will not change
Doc Type is string
DocNo is number
SubDocNo is number



Pls help…

Thanks



 
You havn't said so explicitly but I'm assuming that "Cat", "DocNo" and "SubDocNo" and "IndexNo" are stored in separate fields in the table

If not then AT Least store "Cat"-"DocNo"-SubDocNo" in a separate field to the Index and concatenate when displaying on the Form/Reports

Solution
"SELECT Top 1 IndexNo FROM tblName " _
"WHERE ((fldCat = '" & txtCat & "') " _
"AND (fldDocNo = " & txtDocNo & ") " _
"AND (fldSubDocNo = " & txtSubDocNo & ")) " _
"ORDER BY IndexNo ;"

Will return the current highest value of Index number for the given combination of Cat, DocNo and SubDocNo.
Then increment it and store it in the relevant field

fldxxx represent the table's field names for these values
and
txtxxx represent the controls on the form.



G LS
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top