Can't figure out code!

  • Thread starter Thread starter Mark
  • Start date Start date
M

Mark

In Access 2002. I have two subforms, named Room - Data
Entry and Staff Restrooms Data Entry, on a mainform named
SiteInformation-Building. Within each of the subforms
but not on the mainform I have a "RoomID" field.
Information is entered for RoomID via the "Room - Data
Entry" subform. I want the data that is entered here to
be linked/copied to the "Staff Restrooms Data Entry"
subform. Below is what I have put into the BeforeUpdate
event box of the "Staff Restrooms Data Entry" subform:

=Forms![SiteInformation-Building]!{Room - Data
Entry].Form!RoomID

It does not work. Need help. Thanks in advance!

Mark
 
Mark,
Maybe this will work...In the second subform's design
view, open the Room ID field's properties box. In the
default value property, try:

=Forms![SiteInformation-Building]![Room - Data
Entry]![RoomID]
 
Mark said:
In Access 2002. I have two subforms, named Room - Data
Entry and Staff Restrooms Data Entry, on a mainform named
SiteInformation-Building. Within each of the subforms
but not on the mainform I have a "RoomID" field.
Information is entered for RoomID via the "Room - Data
Entry" subform. I want the data that is entered here to
be linked/copied to the "Staff Restrooms Data Entry"
subform. Below is what I have put into the BeforeUpdate
event box of the "Staff Restrooms Data Entry" subform:

=Forms![SiteInformation-Building]!{Room - Data
Entry].Form!RoomID

It does not work. Need help. Thanks in advance!

This is fairly unorthodox. Are these subforms related to the main form at all? That
is the usual way to create these types of links.

Take another look at the expression you have above.
Exactly _what_ =Forms![SiteInformation-Building]![Room - Data Entry].Form!RoomID

You have to specify a specific field or control name in the assignment for it to do
anything. Something like. . .
Me!RoomID = Forms![SiteInformation-Building]![Room - Data Entry].Form!RoomID
 
Rick, thanks for the reply. The subforms are related
(actually linked) to the mainform via a field named "Site
ID". The code that I indicated below is in the
BeforeUpdate event box within Properties of the "RoomID"
field on the "Staff Restrooms Data Entry" subform. I
have attempted writing the code directly, with VBA as
follows:

Me!RoomID = Forms![SiteInformation-Building]![Room - Data
Entry].Form!RoomID

This did not work so I used the Event builder within the
BeforeUpdate of the RoomID field on the subform. I have
checked spelling and such, but it does to work. I seem
to be missing something very simple but can't see what.
Any suggestions????

Thanks!!!
-----Original Message-----
Mark said:
In Access 2002. I have two subforms, named Room - Data
Entry and Staff Restrooms Data Entry, on a mainform named
SiteInformation-Building. Within each of the subforms
but not on the mainform I have a "RoomID" field.
Information is entered for RoomID via the "Room - Data
Entry" subform. I want the data that is entered here to
be linked/copied to the "Staff Restrooms Data Entry"
subform. Below is what I have put into the BeforeUpdate
event box of the "Staff Restrooms Data Entry" subform:

=Forms![SiteInformation-Building]!{Room - Data
Entry].Form!RoomID

It does not work. Need help. Thanks in advance!

This is fairly unorthodox. Are these subforms related to the main form at all? That
is the usual way to create these types of links.

Take another look at the expression you have above.
Exactly _what_ =Forms![SiteInformation-Building]![Room - Data Entry].Form!RoomID

You have to specify a specific field or control name in the assignment for it to do
anything. Something like. . .
Me!RoomID = Forms![SiteInformation-Building]![Room - Data Entry].Form!RoomID


.
 
Mark said:
Rick, thanks for the reply. The subforms are related
(actually linked) to the mainform via a field named "Site
ID". The code that I indicated below is in the
BeforeUpdate event box within Properties of the "RoomID"
field on the "Staff Restrooms Data Entry" subform. I
have attempted writing the code directly, with VBA as
follows:

Me!RoomID = Forms![SiteInformation-Building]![Room - Data
Entry].Form!RoomID

This did not work so I used the Event builder within the
BeforeUpdate of the RoomID field on the subform. I have
checked spelling and such, but it does to work. I seem
to be missing something very simple but can't see what.
Any suggestions????

I thought you originally stated that you were using the BeforeUpdate of the
form, not the control. I believe it would work there. As the other poster
said, you can't set the value of a control in its own BeforeUpdate event. You
can cancel the event that was about to happen, but you can't change the value.
 
Back
Top