Code wont trigger

G

grubbyr

hi...
I hope someone can help me with this..
I am a newbie so please forgive my ignorance
I am setting up a customer dbase in access 2007
and with help from previous questions and answers on the forum I was
able to set up [First] [Next] [Previous] [Last] record cmd buttons as
below:

The code worked really well...
I shut access down and next day opened it up and now none of my code
works at all...

I cant seem to get it to trigger...
I seemed to have this problem the other day so I did a repair install
of office 2007
and then started from scratch and it worked fine until I shutdown then
rebooted...

Its driving me crazy... please help!

Option Compare Database

Private Sub Form_Current()
' check which record we are on, and enable buttons accordingly

If Me.CurrentRecord = 1 Then
' On the first record, don't need move first or move previous
Me.cmdFirst.Enabled = False
Me.cmdPrevious.Enabled = False

Else
' Not on the first record, do need move first and move
previous
Me.cmdFirst.Enabled = True
Me.cmdPrevious.Enabled = True

End If

Me.Company.SetFocus

' Check if we are on the last record, or a new record...
' if so, disable the next and last buttons
If Me.CurrentRecord >= Me.Recordset.RecordCount Then
' Last record
Me.cmdNext.Enabled = False
Me.cmdLast.Enabled = False

Else
' Not on last record
Me.cmdNext.Enabled = True
Me.cmdLast.Enabled = True

End If

Me.Company.SetFocus

End Sub
 
D

Dale Fye

I think you need to use the recordsetclone rather than the recordset to get
the record count properly. First, I would move the me.Company.Setfocus to
the top of your code

Private Sub Form_Current

Dim bMoveBack as boolean, bMoveFwd as boolean

me.Company.setfocus

bMoveBack = (me.currentRecord > 1)
bMoveFwd = (me.currentrecord < me.recordsetclone.Recordcount

me.cmdFirst.Enabled = bMoveBack
me.cmdPrevious.Enabled = bMoveBack
me.cmdNext.enabled = bMoveFwd
me.cmdLast.Enabled = bMoveFwd

End sub
 
G

grubbyr

I think you need to use the recordsetclone rather than the recordset to get
the record count properly. First, I would move the me.Company.Setfocus to
the top of your code

Private Sub Form_Current

Dim bMoveBack as boolean, bMoveFwd as boolean

me.Company.setfocus

bMoveBack = (me.currentRecord > 1)
bMoveFwd = (me.currentrecord < me.recordsetclone.Recordcount

me.cmdFirst.Enabled = bMoveBack
me.cmdPrevious.Enabled = bMoveBack
me.cmdNext.enabled = bMoveFwd
me.cmdLast.Enabled = bMoveFwd

End sub

--
Email address is not valid.
Please reply to newsgroup only.



grubbyr said:
hi...
I hope someone can help me with this..
I am a newbie so please forgive my ignorance
I am setting up a customer dbase in access 2007
and with help from previous questions and answers on the forum I was
able to set up [First] [Next] [Previous] [Last] record cmd buttons as
below:
The code worked really well...
I shut access down and next day opened it up and now none of my code
works at all...
I cant seem to get it to trigger...
I seemed to have this problem the other day so I did a repair install
of office 2007
and then started from scratch and it worked fine until I shutdown then
rebooted...
Its driving me crazy... please help!
Option Compare Database
Private Sub Form_Current()
' check which record we are on, and enable buttons accordingly
If Me.CurrentRecord = 1 Then
' On the first record, don't need move first or move previous
Me.cmdFirst.Enabled = False
Me.cmdPrevious.Enabled = False
Else
' Not on the first record, do need move first and move
previous
Me.cmdFirst.Enabled = True
Me.cmdPrevious.Enabled = True
End If

' Check if we are on the last record, or a new record...
' if so, disable the next and last buttons
If Me.CurrentRecord >= Me.Recordset.RecordCount Then
' Last record
Me.cmdNext.Enabled = False
Me.cmdLast.Enabled = False
Else
' Not on last record
Me.cmdNext.Enabled = True
Me.cmdLast.Enabled = True
End If

End Sub- Hide quoted text -

- Show quoted text -

Thanks Dale...
I would love to know if it works....

I entered your code, but

I CANT GET ANY CODE TO WORK

I probably mislead you by putting in the code but i thought there may
have been an issue with the beginning of the code..
 
D

Dale Fye

Don't have 2007, so don't know what to tell you.

Have you checked all of your references?
Have you tried Compact & Repair (backup you db first).
Have you tried creating a new (clean) database and importing all of the
objects from the old one?

These are generally the first things I do to troubleshoot this type of
problem, although I gotta say I've never had the specific problem.

Dale
--
Email address is not valid.
Please reply to newsgroup only.


grubbyr said:
I think you need to use the recordsetclone rather than the recordset to get
the record count properly. First, I would move the me.Company.Setfocus to
the top of your code

Private Sub Form_Current

Dim bMoveBack as boolean, bMoveFwd as boolean

me.Company.setfocus

bMoveBack = (me.currentRecord > 1)
bMoveFwd = (me.currentrecord < me.recordsetclone.Recordcount

me.cmdFirst.Enabled = bMoveBack
me.cmdPrevious.Enabled = bMoveBack
me.cmdNext.enabled = bMoveFwd
me.cmdLast.Enabled = bMoveFwd

End sub

--
Email address is not valid.
Please reply to newsgroup only.



grubbyr said:
hi...
I hope someone can help me with this..
I am a newbie so please forgive my ignorance
I am setting up a customer dbase in access 2007
and with help from previous questions and answers on the forum I was
able to set up [First] [Next] [Previous] [Last] record cmd buttons as
below:
The code worked really well...
I shut access down and next day opened it up and now none of my code
works at all...
I cant seem to get it to trigger...
I seemed to have this problem the other day so I did a repair install
of office 2007
and then started from scratch and it worked fine until I shutdown then
rebooted...
Its driving me crazy... please help!
Option Compare Database
Private Sub Form_Current()
' check which record we are on, and enable buttons accordingly
If Me.CurrentRecord = 1 Then
' On the first record, don't need move first or move previous
Me.cmdFirst.Enabled = False
Me.cmdPrevious.Enabled = False
Else
' Not on the first record, do need move first and move
previous
Me.cmdFirst.Enabled = True
Me.cmdPrevious.Enabled = True
End If

' Check if we are on the last record, or a new record...
' if so, disable the next and last buttons
If Me.CurrentRecord >= Me.Recordset.RecordCount Then
' Last record
Me.cmdNext.Enabled = False
Me.cmdLast.Enabled = False
Else
' Not on last record
Me.cmdNext.Enabled = True
Me.cmdLast.Enabled = True
End If

End Sub- Hide quoted text -

- Show quoted text -

Thanks Dale...
I would love to know if it works....

I entered your code, but

I CANT GET ANY CODE TO WORK

I probably mislead you by putting in the code but i thought there may
have been an issue with the beginning of the code..
 
K

KMay

I am replying on the assumption that I am reading your messages correctly.
Your problem is not with this specific code itself but with the fact that
NONE of your code is triggering each time you open Access. Assuming I am
reading that right, I had the same problem this evening (recently upgraded to
Access 07 and am using for first time on previously built DB). What I finally
figured out is that there was a security change in Access 07. In 03, I always
got a popup screen when opening a DB asking me if I trusted the code and
wanted to run it. Anyhow, in 07, that screen no longer appears. Rather,
there is bar at the top underneath the icon ribbons that says "Security
Warning. Certain content in the database has been disabled." There is an
Options button you can click to choose to enable the content (all your
coding). Unfortunately, I have yet to figure out how to always enable the
content for a specific database without enabling ALL content for ALL
databases (which I don't want to do). But it could be that the content in
your DB is disabled automatically upon each open and you need to click the
Options button to enable it.
 
D

Dale Fye

Don't know anything about 07, but my guess is that if you Google on the
following, you will figure it out.

"digital signature" +Microsoft + Access +2007

HTH
Dale

KMay said:
I am replying on the assumption that I am reading your messages correctly.
Your problem is not with this specific code itself but with the fact that
NONE of your code is triggering each time you open Access. Assuming I am
reading that right, I had the same problem this evening (recently upgraded
to
Access 07 and am using for first time on previously built DB). What I
finally
figured out is that there was a security change in Access 07. In 03, I
always
got a popup screen when opening a DB asking me if I trusted the code and
wanted to run it. Anyhow, in 07, that screen no longer appears. Rather,
there is bar at the top underneath the icon ribbons that says "Security
Warning. Certain content in the database has been disabled." There is an
Options button you can click to choose to enable the content (all your
coding). Unfortunately, I have yet to figure out how to always enable the
content for a specific database without enabling ALL content for ALL
databases (which I don't want to do). But it could be that the content in
your DB is disabled automatically upon each open and you need to click the
Options button to enable it.

grubbyr said:
hi...
I hope someone can help me with this..
I am a newbie so please forgive my ignorance
I am setting up a customer dbase in access 2007
and with help from previous questions and answers on the forum I was
able to set up [First] [Next] [Previous] [Last] record cmd buttons as
below:

The code worked really well...
I shut access down and next day opened it up and now none of my code
works at all...

I cant seem to get it to trigger...
I seemed to have this problem the other day so I did a repair install
of office 2007
and then started from scratch and it worked fine until I shutdown then
rebooted...

Its driving me crazy... please help!

Option Compare Database

Private Sub Form_Current()
' check which record we are on, and enable buttons accordingly

If Me.CurrentRecord = 1 Then
' On the first record, don't need move first or move previous
Me.cmdFirst.Enabled = False
Me.cmdPrevious.Enabled = False

Else
' Not on the first record, do need move first and move
previous
Me.cmdFirst.Enabled = True
Me.cmdPrevious.Enabled = True

End If

Me.Company.SetFocus

' Check if we are on the last record, or a new record...
' if so, disable the next and last buttons
If Me.CurrentRecord >= Me.Recordset.RecordCount Then
' Last record
Me.cmdNext.Enabled = False
Me.cmdLast.Enabled = False

Else
' Not on last record
Me.cmdNext.Enabled = True
Me.cmdLast.Enabled = True

End If

Me.Company.SetFocus

End Sub
 

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

Top