Macro to enter data into subform (1 Viewer)

tinher

Registered User.
Local time
Yesterday, 18:13
Joined
May 11, 2019
Messages
30
Hi,

I created a macro on a subform that does setProperty value to Bob in the helper field.

Works for first record in subform.

I only have 3 helpers Bob, Susan and Sam so I created 3 macros for each value.

So I created 3 macros they work fine. The problem is how do I make them move to new record.

some times Bob and Susan help and or all three help so I need 3 records added.

example if I run the Bob macro my macro adds the first record with Bob name. Then if I run the Sam macro it changes Bob to Sam in same record. Then if I run the Susan macro it changes Sam to Susan.

I want it to add a record for Bob when I run the Bob macro and add a record for Sam when I run the Sam macro. So I can see that Bob and Sam were helpers.

Thank you.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 18:13
Joined
Oct 29, 2018
Messages
21,358
Hi. Can you show us your macro code?
 

tinher

Registered User.
Local time
Yesterday, 18:13
Joined
May 11, 2019
Messages
30
I created a button and the on click is set to

SetProperty
ControlName Helper
Property Value
Value Bob

I need to add something that changes focus to next record but everything I have tried gives me an error.

This is in a subform so when I use goto new record or next record it says the form is not open

I tried the after update on the helper field also.


Thank you.
 
Last edited:

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 01:13
Joined
Jul 9, 2003
Messages
16,245
There are different ways of interpreting the problem. The first thing is the subform could either be in datasheet or form view. I suspect you mean it's in form view, however it would be beneficial to know for sure.

I would suggest you create a demonstration database, just the basic components extracted from your existing database to demonstrate what you have and if you can, indicate the results you want. If that's not possible, then some screenshots might provide enough information.

I personally wouldn't enter data directly into a form with code, I would enter it into the table underlying the form using an SQL Statement.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 18:13
Joined
Oct 29, 2018
Messages
21,358
I created a button and the on click is set to

SetProperty
ControlName Helper
Property Value
Value Bob

I need to add something that changes focus to next record but everything I have tried gives me an error.

This is in a subform so when I use goto new record or next record it says the form is not open

I tried the after update on the helper field also.


Thank you.
Hi. I just gave it a try and didn't get any error when I told the macro to go to a new record. Here's what my macro looked like:


 

Attachments

  • macro.png
    macro.png
    6.8 KB · Views: 163

Users who are viewing this thread

Top Bottom