broken code?

A

- Alex

This is the oddest thing I've ever run into in my short 3 years of coding, so
take a look if you've run into this in Access before any help would be
appreciated exponentally.

the Code :

Private Sub Form_Current()
If Me.CurrentRecord = 1 Then
Me.btnSubFormPreviousRecord.Enabled = False
Else
Me.btnSubFormPreviousRecord.Enabled = True
End If

If Me.Recordset.RecordCount < 1 Then
Me.btnAddNewItem.Enabled = False
Else
Me.btnAddNewItem.Enabled = True
End If

If Me.CurrentRecord = Me.Recordset.RecordCount Or
Me.Recordset.RecordCount < 1 Then
Me.btnSubFormNextRecord.Enabled = False
Else
Me.btnSubFormNextRecord.Enabled = True
End If
End Sub

'and in a subform to that form

Private Sub Form_Current()
If Me.Recordset.AbsolutePosition + 1 = Me.Recordset.RecordCount Then
Me.btnMainFormNext.Enabled = False
Else
Me.btnMainFormNext.Enabled = True
End If

If Me.CurrentRecord = 1 Then
Me.btnMainFrmPrevious.Enabled = False
Else
Me.btnMainFrmPrevious.Enabled = True
End If
End Sub

The Program :

Main form holds a set of records and has a manually created next record and
previous record button that shift the subform records in the regular manner.
The subform has a next, previous, and new record button. the new record
button should be disabled when there are no records, the next and previously
act normally.

The Complication :

The code is solid were that the probelm this would be simple. Everytime I
start the main form, both buttons are Disabled, even though there are 14
records on the main form, and all three buttons on the sub form are disabled
even though theres a multitude of records on that one. Once I am able to for
the records to move manually (say, roll the mouse button) then it works fine,
except the subform that disables both once I move tha main form again. Now
heres where it get freaky.

When I break, and step threw the code, line by line, it works fine, all the
right buttons (in the case of the open main form the next button) are
enabled. but as soon as I stop breaking threw the code again it breaks, once
more. The Kicker? my boss suggests that i delete and recode, so I do, it
work for about 2 start-ups then breaks again. I just have no idea why or how
this is doing this, if anyone has any solutions, ideas, leads, anything to go
on, I wouold be in your debt.

If this helps :

When I step threw the code in the form_Current event of the subform it runs
anywhere from 1 to 4 times when I change the main form.

- Alex
 

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