By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,831 Members | 1,031 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,831 IT Pros & Developers. It's quick & easy.

last record on cmobo box

P: n/a
dear gurus,

can any one help me to how to store progrmatically last value in combo
box. say i load access form. but in combo box the last value how it
will come

any ideas...as i need only programatically

regards,

shahzad

Nov 13 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
How about

Private Sub Command36_Click()
Dim ctl As ComboBox
Set ctl = Me.UnitID

'ctl.ListCount

MsgBox ctl.ListCount
Set ctl = Nothing
End Sub

ctl.ListCount returns the count of items in the control's list...

Sounds like you give up waaaay too easily!! (How do you learn to
program if you do that?)

Nov 13 '05 #2

P: n/a
If I understand you correctly, you want a combobox on your form to display a
record just added on that same form. You'll need to add a line of code to
the OnEntry event of the combobox:
Me!cmbNameofComboboxControl.requery

Now new records will be shown in the combobox.
-Ed

"SalimShahzad" <sa**********@gmail.com> wrote in message
news:11**********************@c13g2000cwb.googlegr oups.com...
dear gurus,

can any one help me to how to store progrmatically last value in combo
box. say i load access form. but in combo box the last value how it
will come

any ideas...as i need only programatically

regards,

shahzad

Nov 13 '05 #3

P: n/a

SalimShahzad wrote:
dear gurus,

can any one help me to how to store progrmatically last value in combo box. say i load access form. but in combo box the last value how it
will come

any ideas...as i need only programatically

regards,

shahzad

to get it...

Me.UnitID.ListIndex = Me.UnitID.ListCount - 1

where did you want to store it? You could...
1. write it on a piece of paper
2. write it to a custom property
3. write it to a table
4. write it into the tag property of some control
5. memorize it...

Nov 13 '05 #4

P: n/a
dear gurus,

the combo box is fill with some value bound control from table...
say i have claim no series like a001,a002,a003....a00n so on

so now when the forms load, and when the user click on combo box while
a new record inserting...a new value required to generate...for this i
write a seprate codes to gernate auto claim no...but i could nt find a
way how to get by programming last claimno based on sql query and then
select the claim no, auto assign a new number and insert new record
based on last claim no..this is the whole idea...

to create or get last claim no using VBA i want to ask u, to create
auto gernatre no here r the codes

Private Const strC = "A"
Private Sub Command1_Click()
Dim stra, stre As String
Dim intb, intd As Integer
Dim strd As String
stra = "200"
intb = Val(stra) + 1
intd = Len(CStr(intb))
stre = String(4 - intd, "0") & CStr(intb)
MsgBox strC & stre
End Sub

so the above serial wil start say a001,a002

Nov 13 '05 #5

P: n/a
SalimShahzad wrote:
dear gurus,

can any one help me to how to store progrmatically last value in combo
box. say i load access form. but in combo box the last value how it
will come

any ideas...as i need only programatically

regards,

shahzad


I created a combo box with the values One, Two, Three. In the OnOpen
event I entered
MsgBox Me.Combo0.ItemData(Me.Combo0.ListCount - 1)
and it displays
Three
Nov 13 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.