newrecord property

khurram7x

Registered User.
Local time
Today, 06:44
Joined
Mar 4, 2015
Messages
226
Is there a macro which captures new record in a table or form please??
I want to place button on a form which should only appear for a new record form.

Thanks.
 
Use the Form Current Method. Something like,
Code:
Private Sub Form_Current()
    Me.YourButtonName.Visible = Me.NewRecord
End Sub
 
Use the Form Current Method. Something like,
Code:
Private Sub Form_Current()
    Me.YourButtonName.Visible = Me.NewRecord
End Sub

Thanks eugin, I understand this is a simple code but is there a Macro variant please. I've not started learning VBA yet and trying to work things around with Macros for now.
It'll be easy for me to understand.
 
I do not think Macros are capable of doing this. I think it is time for you to move away from Macros ;)

Here is how you create a VBA. Click on the Form Design, then find the Form Current Event in the Event Tab. When you click the three dots (...), it will pop up with the option Choose Builder. The options are "Macro Builder", "Expression Builder", "Code Builder".

Select Code Builder and click OK. You will be taken to the VBA window, just use Me. and follow the name of the button then .Visible = Me.NewRecord. Simples.
 
I do not think Macros are capable of doing this. I think it is time for you to move away from Macros ;)

Here is how you create a VBA. Click on the Form Design, then find the Form Current Event in the Event Tab. When you click the three dots (...), it will pop up with the option Choose Builder. The options are "Macro Builder", "Expression Builder", "Code Builder".

Select Code Builder and click OK. You will be taken to the VBA window, just use Me. and follow the name of the button then .Visible = Me.NewRecord. Simples.
Great... it worked exactly as i wanted, thanks :)
Why do we use Me. in VBA code?

I'm looking forward to start working on VBA in next couple months. I just started Access 40-60 days back, so I'm looking to make all components work together before I spend myself for VBA. I'm working on one design book as well.
 
Why do we use Me. in VBA code?

Me is the Current Context Object. In practice it usually means the form object associated with the code.

If you don't include it and simply refer to the name of an object on the form, Access will first look for a VBA variable by the name, then objects in the form's Controls Collection, then fields in the Form's recordset.
 
Thank you.
One last thing please. What if I need to hide control on a new user form, like search box etc.?
I've done it like this. Is this an ok way?

If Me.NewRecord Then
Me.cbxSearch_Label.Visible = False
Me.cbxSearch.Visible = False
Else
Me.cbxSearch_Label.Visible = True
Me.cbxSearch.Visible = True
End If
 
Last edited:
Could you please explain what you mean by
..... new user form,
Have you actually tried this? It looks OK !
I've done it like this. Is this an ok way?

If Me.NewRecord Then
Me.cbxSearch_Label.Visible = False
Me.cbxSearch.Visible = False
Else
Me.cbxSearch_Label.Visible = True
Me.cbxSearch.Visible = True
End If
 

Users who are viewing this thread

Back
Top Bottom