Solved

Macro to conditionaly apply a value to a control

Posted on 2013-12-06
7
322 Views
Last Modified: 2013-12-08
I have a form frmCompanies on which a record ComID is selected.

Then I open a form frmNotes with a macro filtering all notes in tblNotes where ComID = frmCompanies.[ComID].Value.

Now when I decide to make a new note, I want the frmNotes.[ComID].Value must also be set equal to frmCompanies.[ComID].Value.

I was thinking to use On Dirty as trigger to achieve this. However I don't find a way to allocate a value of a control from another form to a control on the active form.

I do not want to use a subform.

I do not have experience with macros, so this is the first one. I know VBA.

Any help please.
0
Comment
Question by:Fritz Paul
  • 3
  • 2
  • 2
7 Comments
 
LVL 30

Expert Comment

by:hnasr
ID: 39700627
Upload a sample database,  removing any object but the ones needed to show the issue.
0
 

Author Comment

by:Fritz Paul
ID: 39700680
Attached is the applicable database. It will open with frmCompanies and if you click on "Open frmNotes" button, the second form will open.

Thanks.
Action.accdb
0
 
LVL 30

Expert Comment

by:hnasr
ID: 39700765
Try this:

Private Sub Form_Dirty(Cancel As Integer)
    Me.ComID = Me.Tag
End Sub

Private Sub Form_Open(Cancel As Integer)
    Me.Tag = Me.ComID
End Sub

Open in new window

Action.accdb
0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 

Author Comment

by:Fritz Paul
ID: 39700793
Hi, Sorry if I created a misunderstanding.

I specifically want to use a macro for this purpose, because I want the experience and I want to create a web database.

Thanks for your attension. Can you help with an Access 2010 macro?
0
 
LVL 34

Accepted Solution

by:
PatHartman earned 500 total points
ID: 39703656
If you are creating a web database with A2010, you are wasting your time.  That technology is already deprecated.  The A2013 version of web databases is quite different.

Use the BeforeInsert event.  You only want to populate the ID if this is a new record.  Use the macro builder to build it.
0
 

Author Closing Comment

by:Fritz Paul
ID: 39704264
Thanks for your comment about A2010 web databases and
your answer to my question.
Also thanks for the other contributions.
Fritz
0
 
LVL 34

Expert Comment

by:PatHartman
ID: 39704887
You are quite welcome:)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now