[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 384
  • Last Modified:

Macro to conditionaly apply a value to a control

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
Fritz Paul
Asked:
Fritz Paul
  • 3
  • 2
  • 2
1 Solution
 
hnasrCommented:
Upload a sample database,  removing any object but the ones needed to show the issue.
0
 
Fritz PaulAuthor Commented:
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
 
hnasrCommented:
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
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
Fritz PaulAuthor Commented:
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
 
PatHartmanCommented:
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
 
Fritz PaulAuthor Commented:
Thanks for your comment about A2010 web databases and
your answer to my question.
Also thanks for the other contributions.
Fritz
0
 
PatHartmanCommented:
You are quite welcome:)
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now