display a field from another form

S

SylvieB

I have two forms. Let’s say Form1 and Form2. I need to write a code that when
the user puts a checkmark on the box in Form1, it displays “record closed†on
form2. The field on form2 is Record. It is a text box. My code does not work.
I am not sure how to call a field from a different form.
Here is the code I have so far:
Private Sub chkClose_AfterUpdate()
If Me!chkClose = True Then
Form_from2.Record = “record closedâ€
Else
Me!txtClose = Null
Me.Dirty = True
End Sub
Thanks in advance for any help.
 
D

Damon Heron

First, you need to check if the form2 is loaded:

If Application.CurrentProject.AllForms!form2.IsLoaded Then
If Me!chkClose = True Then
Forms!form2!Record = "Record Closed"
End If
end if

Also, I would consider re-naming the textbox "record" to perhaps
"txtRecord".

Damon
 
D

Dorian

The correct syntax is [Forms]![form-name].[control-name] =
Of course, this will only work if the form is open.
-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top