hidden botton wont show when browsing duplicated record

almost

New Member
Joined
Jan 29, 2017
Messages
2
hi, im sorry for the bad title but english isnt my first language.

im trying to make a botton to show when a adding a duplicated record in the form, it works fine when i add a new record in the form, but when i brows a form it wont show, how i can make it show when i brows the form?

botton name : command01
record name : account
form name : All
table name: All


Code:
Private Sub account_AfterUpdate()If (Eval("DLookUp(""[account]"",""[all]"",""[account] =form![account]"") Is Not Null")) Then
Me.Command01.Visible = True
  End If
End Sub




Code:
Private Sub Form_Current()
Me.Command01.Visible = False
End Sub


thanks for taking your time reading my problem
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
I haven't tested this, but I think it should do the trick:

Code:
Private Sub Form_AfterUpdate()
  Call ToggleVisible
End Sub

Private Sub Form_Current()
  Call ToggleVisible
End Sub

Private Sub ToggleVisible()
  If DCount("*", "all", "account = " Me.account.Value) > 1 Then
    Me.Command01.Visible = True
  End If
End Sub
 
Last edited:
Upvote 0
I haven't tested this, but I think it should do the trick:

Code:
Private Sub Form_AfterUpdate()
  Call ToggleVisible
End Sub

Private Sub Form_Current()
  Call ToggleVisible
End Sub

Private Sub ToggleVisible()
  If DCount("*", "all", "account = " Me.account.Value) > 1 Then
    Me.Command01.Visible = True
  End If
End Sub


sorry, it didn't do the job, there was an error
 
Upvote 0
You won't get an after_update() event when browsing (navigating) a form. You need to put the same kind of check you did in the after update event into the current event - looks like what the above post did, except probably the code needs proper quoting for text values in the where part of the function.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,221,771
Messages
6,161,847
Members
451,723
Latest member
Rachetsely

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top