Binding SubForms to UnBound Main Form

JonMulder

Registered User.
Local time
Today, 14:18
Joined
Apr 9, 2011
Messages
23
Greetings,

I've got a main form with four subforms for adding or editting data. The subforms are for comments about various aspects of the main form.

The main form is unbounded. I've done this because I don't want the user to commit the changes/additions until they hit the Save button at which time changes are made to the underlying databases.

Briefly the structure is as follows (main form composed of a query of 4 tables):

Main Form ______________________SubForms
WellLocationNumber ______________WellLocationComments
DateLoggerSerialNumber ___________DataLoggerComments
CableSerialNumber ________________CableComments
LoggingEventNumber ______________LoggingEventComments

In my code, I inserted:
Me.SubFormDataLoggerLocationComments.LinkMasterFields = Me.TextBoxSWN.Value
Me.SubFormDataLoggerLocationComments.LinkChildFields = Me.TextBoxSWN.Value

The code work but I get a message box saying "Enter Parameter Value" containing the actual value of my well location number (i.e., "14N01E35P004M"), like when you do a "booboo" in a query.

I don't know. Maybe, my logic is too convoluted. Now to take this a step further, I'd really like to use temp tables for my comment subforms if adding a record, or the existing tables if editting a record. Again, it's because I don't want those added comments committed to the table until the Save button is pressed (in the case of a new parent record).

Any help or suggestions would be appreciated.

Thanks,

Jon Mulder
Durham, California
 
This line:
Code:
Me.SubFormDataLoggerLocationComments.LinkChildFiel ds = Me.TextBoxSWN.Value

Seems to be incorrect. it should be just the column name of the foreign key for your subform. As a reference, have a look at FMS Inc. synchronized subform.
 
Thanks for your response. I tried:

Me.SubFormDataLoggerLocationComments.LinkChildFields = "[DataLoggerComments].[DataLoggerLocationSWN]"

where "[DataLoggerComments].[DataLoggerLocationSWN]" is the actual name of the related field in the subform.

When I did that, I got more dialog boxes coming up!

I'm just a bit clueless about proper syntax -- are quotes needed? Are brackets needed? Do I need to preface the field name with table name?

I took a look at the link but didn't see any specific code that I could try out. I'll go back there and download the database.

Again, thanks for your suggestion.
 
You got the right idea, but I think you only need this:

Code:
DataLoggerLocationSWN

for your child field links.

Brackets are object identifiers and only required when you have a name that has characters that would be ambiguous. An example is when you have a table named "My Table", spaces makes it ambiguous - is it actually a single object name or is it saying there's a object named "My" and it should be aliased as "Table"? Thus surrounding the brackets are required for "My Table" but not "myTable".

I don't think you need quotes since it is a string delimiter but you want to pass in an object reference. For child links specifically, there's no need to preface with the table name, though if your query has multiple columns of same name from different tables you definitely want to alias them in the query itself to remove any ambiguity. Else, Access rename for you but it can get messy.

I hope that helps.
 
Thank you!

In the meantime, I took at the database in the link you referred me to. Now, I see that the linking to a textbox can actually be done in the properties of the subform. That makes it much easier than coding.

BTW, thanks for the info on brackets, etc; not always sure when to "tighten" my code.

It's been a long night here in California trying to figure this our. Now, on to more obstacles, I'm sure!

JonMulder
Durham, California
 

Users who are viewing this thread

Back
Top Bottom