In a "Select Case" statement I would like to tell :"Case is" last record in database.
What is the right syntax ??
In a "Select Case" statement I would like to tell :"Case is" last record in database.
What is the right syntax ??
See http://www.techonthenet.com/access/f...anced/case.php
and No you would'nt use that to get the last record.
You could do something like
rs.movelast
.. do something here
maybe I was not clear.
Here is my code :
Select Case [ID]
Case Is = "1"
Me.Comando484.Visible = False
Me.Comando485.Visible = True
Case Max(ID) 'here is where I don't know exact syntax
Me.Comando484.Visible = True
Me.Comando485.Visible = False
Case Else
Me.Comando484.Visible = True
Me.Comando485.Visible = True
End Select
Any hint ?
A couple of things -
1. ID, if it is an autonumber, is not necessarily going to be the largest and the last record. Autonumbers, even if they are set to increment, can actually go random or negative numbers. So, unless you are using another method, you don't want that.
2. If ID is numeric you don't use quotes around the 1 in the Case. You would just use
Case 1
3. This code should work:
Code:Private Sub Form_Current() Dim rst As DAO.Recordset Set rst = Me.RecordsetClone rst.MoveLast Select Case Me!ID Case 1 Me.Comando484.Visible = False Me.Comando485.Visible = True Case rst!ID Me.Comando484.Visible = True Me.Comando485.Visible = False Case Else Me.Comando484.Visible = True Me.Comando485.Visible = True End Select rst.Close Set rst = Nothing End Sub
works like a charm
thanks a ton!