How to show a record to edit using a non-number field from subform?

xwnoob

Registered User.
Local time
Today, 00:04
Joined
Nov 7, 2011
Messages
70
Hi,

I have a edit section in my database that has a listbox that displays records by clicking on a button. I use the following code to excecute the command:

DoCmd.OpenForm "Formname", , , _
"[tblname].[fieldname]=" & "'" & Me.typelistnamehere.Column(0) & "'"
'Close the dialog box
DoCmd.Close acForm, "Edit Form"

THis is a form that has a subform.

Ok, So the above code only works when i REFER to a fieldname that is a text datatype like "Titlename".I dont why it works that way but it does. Now, this particular main form only has two fields:Both which are number fields "CommitmentID" and "BorrowerID(FK)". The subform has textfields like FacilityName.
The problem is that i always cant refer to the subform field to OPEN the MAIN FORM. Whenever i do the following code:

Code:
DoCmd.OpenForm "AddCommitmentDetail", , , _
        "[tblFacilitySub].[FacilityName]=" & "'" & Me.ListShowCommit.Column(2) & "'"
        'Close the dialog box
        DoCmd.Close acForm, "SelectEditCommitment"

Access just asks me for the parameter value of facilityname. I think this is because the mainform table is actually tblCommitment and i cant refer to another table that is called tblFacilitySub.This table is the control source of my subform. So any ideas how to solve this? I have done this previously with success but only using text fields....
 
The Where Condition argument refers to a field in the recordset of the form. A fieldname my appear as tablename.fieldname in the query but that does not mean the name of the field is [tablename].[fieldname] as such.The brackets delimit an object name so the name might be [tablename.fieldname]Better to alias any fieldnames that are ambiguous so they have a single name in the recordset. Dots are a bad thing in a name and Access won't tolerate them in some places.​
 
The Where Condition argument refers to a field in the recordset of the form. A fieldname my appear as tablename.fieldname in the query but that does not mean the name of the field is [tablename].[fieldname] as such.The brackets delimit an object name so the name might be [tablename.fieldname]Better to alias any fieldnames that are ambiguous so they have a single name in the recordset. Dots are a bad thing in a name and Access won't tolerate them in some places.

Hi i tried doing the [tablename.fieldname] method but access said invalid bracketing 3126
 

Users who are viewing this thread

Back
Top Bottom