Re: Access can't find the field referenced in your expression

MPS wrote:
I have a main form "Main" and a sub form "Sub" - the subform contains
a list of relevant documents that I might want to associate with a
record in the form on Main. These documents are contained in a table
and include a field that has a hyperlink to them.

I'm trying to use the AfterUpdate event - after the user selects a
document from the dropdown list, I want the form to automatically copy
in the hyperlink.

Private Sub Document_AfterUpdate()
Dim stDocName As String
Dim stLinkCriteria As String

'[fx-get document] is a form created just for accessing the
documents in their table
stDocName = "fx - get document"

stLinkCriteria = "[evTitle]=" & "'" & Me![Evidence] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Dim doc_location As String

'DM_Other_Location contains the hyperlink <<<< it breaks here
- can't find DM_Other_Location
doc_location = Forms![fx - get document]!DM_Other_Location.Text


'Now put the hyperlink into the desired field
Forms![analysis-document subform]!Location.SetFocus
Forms![analysis-document subform]!Location.Text = doc_location

End Sub

Hash: SHA1

Make sure you're spelling the control's name correctly. I just copy the
name from the Control's Name property and paste it into my VBA code to
be sure. You don't need to use the .Text property when assigning a
value to the control. In Access VBA the default is .Value. The .Text
property is the display field of the control.

MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
** Respond only to this newsgroup. I DO NOT respond to emails **

Version: PGP for Personal Privacy 5.0
Charset: noconv