Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Prompt Use To Click Command Button If Record has Changed

Status
Not open for further replies.

kristi1023

Programmer
Jan 8, 2002
59
US
I have a subform which consists of 20 unbound checkboxes. The command button runs sql to insert or delete an individual record from a table based on whether a box is checked or has been unchecked. This works great.

I need to prompt the user to click the button only when data has changed, i.e. a box that was checked is unchecked or a new box is checked. How can I do this? Would an event procedure on the main form or the subform used to execute 'Call Me.Update_Click' work? I tried to add the Call to a Next navigation button that is on the main form, but I get an error that this type of call is not supported.

Thank you!
 
How are ya kristi1023 . . .

In VBA help have a look at the [blue]OldValue[/blue] property . . .

Calvin.gif
See Ya! . . . . . .
 
BTW, was interested in this subject (to set up and "undo" feature before sving edits) and followed Aceman1's advice. Acc2000's help gives the following sub:

Sub btnUndo_Click()
Dim ctlTextbox As Control
For Each ctlTextbox in Me.Controls
If ctlTextbox.ControlType = acTextBox Then
Sub btnUndo_Click()
Dim ctlTextbox As Control
For Each ctlTextbox in Me.Controls
If ctlTextbox.ControlType = acTextBox Then
ctlTextbox.Value = ctl.OldValue
End If
Next ctlTextbox
End Sub
End If
Next ctlTextbox
End Sub

Problem is it doesn't work! The line:

ctlTextbox.Value = ctl.OldValue

should be:

ctlTextbox.Value = ctlTextbox.OldValue

Ain't bad enough Access is so quirky; now they have to give buggy examples!

The Missinglinq

There's ALWAYS more than one way to skin a cat!
 
Thank you TheAceMan1 and Missinglinq. I tried using OldValue, but it's not working. I think it's b/c my checkboxes are unbound.

Any other thoughts?
 
Yes it has to be bound to work. Maybe something like this
Code:
public chkOneOriginalValue as boolean
public chkTwoOriginalValue as boolean
....
public chkNOriginalValue as boolean

private sub form_Current()
  chkOneOriginalValue = me.chkBoxOne.value
  chkTwoOriginalValue = me.chkBoxTwo.value
  ....
   chkNOriginalValue = me.chkBoxN.value
end sub

Private Sub Form_BeforeUpdate(Cancel As Integer)
  if chkOneOriginalValue = me.chkBoxOne.value then
     call someFunction(someParameters)
  end if
  if chkTwoOriginalValue = me.chkBoxTwo.value then
    call someFunction(someParameters)
  end if
End Sub
 
Thank you MajP. I've tried all weekend to get this to work with no success, so I've modified my goal.

Can I set Me.Update.Enabled=False on the Click event and then test to see if the button is enabled before proceeding to the next record? If it is enabled, then set a msgbox to prompt the user to click the button?

If the above would work, what event should I put the test and msgbox on? Should I put it on the main form or subform(button is on the subform)?

Thank you so much in advance! This is driving me crazy!%-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top