combobox coding

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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?
 
In the After Update event of the combo where you select the SMID:

Me.txtInterImNumber = Nz(DLookup("[interimnumber]", "TableName", _
"[SMID] = " & Me.cboSMID),0) +1
 
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?
 
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?
 
..

--
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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top