combobox coding

P

Pitu

I have a table with combination of 2 columns named "SMID" which is a lookup
field and "interimnumber" as a primary key. Now i have a form in which the
user selects the "SMID" from the drop down combobox. what i want is the
"interimnumber to be generated in increament of 1 than the previous number
generated. eg. if the last number generated was SMID = 1 and interimnumber =
2 then when the user selects SMID = 1 from the drop down it should
automatically fill interimnumber = 3. and when the user selects SMID=2 it
should start with interimnumber = 1 and then onwards increment to interim
number =2 and so on. How can i do this?
 
K

Klatuu

In the After Update event of the combo where you select the SMID:

Me.txtInterImNumber = Nz(DLookup("[interimnumber]", "TableName", _
"[SMID] = " & Me.cboSMID),0) +1
 
P

Pitu

It works fine for 1st 2 number generated but then 3rd time it gives error
that the record cannot be saved as it will create a duplicate value.

Klatuu said:
In the After Update event of the combo where you select the SMID:

Me.txtInterImNumber = Nz(DLookup("[interimnumber]", "TableName", _
"[SMID] = " & Me.cboSMID),0) +1

Pitu said:
I have a table with combination of 2 columns named "SMID" which is a lookup
field and "interimnumber" as a primary key. Now i have a form in which the
user selects the "SMID" from the drop down combobox. what i want is the
"interimnumber to be generated in increament of 1 than the previous number
generated. eg. if the last number generated was SMID = 1 and interimnumber =
2 then when the user selects SMID = 1 from the drop down it should
automatically fill interimnumber = 3. and when the user selects SMID=2 it
should start with interimnumber = 1 and then onwards increment to interim
number =2 and so on. How can i do this?
 
K

Klatuu

If it worked for the first 2, then it works. Check the data in your table.
I'm sure you will find that that number has already been used.

Pitu said:
It works fine for 1st 2 number generated but then 3rd time it gives error
that the record cannot be saved as it will create a duplicate value.

Klatuu said:
In the After Update event of the combo where you select the SMID:

Me.txtInterImNumber = Nz(DLookup("[interimnumber]", "TableName", _
"[SMID] = " & Me.cboSMID),0) +1

Pitu said:
I have a table with combination of 2 columns named "SMID" which is a lookup
field and "interimnumber" as a primary key. Now i have a form in which the
user selects the "SMID" from the drop down combobox. what i want is the
"interimnumber to be generated in increament of 1 than the previous number
generated. eg. if the last number generated was SMID = 1 and interimnumber =
2 then when the user selects SMID = 1 from the drop down it should
automatically fill interimnumber = 3. and when the user selects SMID=2 it
should start with interimnumber = 1 and then onwards increment to interim
number =2 and so on. How can i do this?
 
B

Brian

..

--
BRIAN LEDBETTER
Klatuu said:
If it worked for the first 2, then it works. Check the data in your table.
I'm sure you will find that that number has already been used.

Pitu said:
It works fine for 1st 2 number generated but then 3rd time it gives error
that the record cannot be saved as it will create a duplicate value.

Klatuu said:
In the After Update event of the combo where you select the SMID:

Me.txtInterImNumber = Nz(DLookup("[interimnumber]", "TableName", _
"[SMID] = " & Me.cboSMID),0) +1

:

I have a table with combination of 2 columns named "SMID" which is a lookup
field and "interimnumber" as a primary key. Now i have a form in which the
user selects the "SMID" from the drop down combobox. what i want is the
"interimnumber to be generated in increament of 1 than the previous number
generated. eg. if the last number generated was SMID = 1 and interimnumber =
2 then when the user selects SMID = 1 from the drop down it should
automatically fill interimnumber = 3. and when the user selects SMID=2 it
should start with interimnumber = 1 and then onwards increment to interim
number =2 and so on. How can i do this?
 
Top