new record, testing for

aidan

Registered User.
Local time
Today, 13:34
Joined
May 23, 2005
Messages
34
I need to disable a custom goto next record button. How do I find out if the current record is both the last and new or if a new record is possible?

Many thanks in advance,

Aidan
 
These are the ways I've tried so far:

1st:

If .CurrentRecord > Me.RecordsetClone.RecordCount + 1 Then
.RecordForward.Enabled = False
Else
.RecordForward.Enabled = True
End If

2nd:
'if current record is last and cid is null then disable
If .CurrentRecord = Me.RecordsetClone.RecordCount Then
If IsNull(Me.CID) Then
.RecordForward.Enabled = False
End If
End If
3rd:
If .RecordsetClone.AbsolutePosition + 1 = .RecordsetClone.RecordCount Then
.RecordForward.Enabled = False
End If

None of them make the damned thing disable however..
 
If you want to disable a command button if the current record is a "New Record" this will do it. Change "NameOfYourCommandButton" to suit and then put the code in the On Current Event of your form.

Code:
If Me.NewRecord Then
Me.NameOfYourCommandButton.Enabled = False

Else

Me.NameOfYourCommandButton.Enabled = True

End If

Sorry, I don't understand what you mean.

How do I find out if the current record is both the last and new or if a new record is possible?
 
Code:
[COLOR=Green]'enables and/or disables command button with one line of code[/COLOR]
Me.YourCmdButton.Enabled = Not Me.NewRecord
Code:
Dim rst As DAO.Recordset
Dim IsLast as Boolean
Set rst = CurrentDb.OpenRecordset( _ ...
With rst
  ...
[COLOR=Green]  'if the recordset has been populated, then 
  'IsLast = true when you are on the last record[/COLOR]
  IsLast = (.RecordCount = .AbsolutePosition + 1)
End with
 
didn't know about .newrecord - thanks both (no message)

thanks

aidan
 

Users who are viewing this thread

Back
Top Bottom