Re: Lookup Field in form from subform

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance




Hi John
Sorry about the confusion, off course it is the tables that have a
relationship. I have tried Dlookup (with the table names) but the field then
just stays blank.
Do you have an idea why?

The tables have the same name as the forms, could that be a problem?

Signe

John Vinson wrote:
>>Hi
>>I have a subform A (with a main form B) and another form C. I want to look up
>>a field in Form C and add it to a field in subform A. The to forms (A and C)
>>are linked in a one to many relationsship.
>
>Whoa. Stop right there.
>
>Forms are JUST WINDOWS. They do not contain data. You cannot "look up
>a field" in Form C - you can reference the value of a Control on form
>C to see the value of a current record. Forms are NOT "in a one to
>many relationship" - only Tables can participate in relationships!
>
>The data is not stored in form C; it's stored in a Table, whatever
>table you're using as Form C's Recordsource. If you want data, get it
>from the Table, not from the form; DLookUp is one way to do so:
>
>DLookUp("[fieldname]", "[tablename]", "[IDfield] = " & [txtID])
>
>will look up the value of fieldname from tablename where the value of
>IDfield in the table is equal to the value in textbox txtID on the
>current form.
>
> John W. Vinson[MVP]


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-forms/200507/1
.



Relevant Pages

  • Re: Referencing a control on a sub form (Post 2) help, please?
    ... control on the subform. ... "John W. Vinson" wrote: ... Could it be that DLookup ...
    (microsoft.public.access.forms)
  • x-post from previous question
    ... Original post: ... My response to John: ... data into the subform with it set to yes. ... Johns response: ...
    (microsoft.public.access.forms)
  • Re: Append import data to existing record
    ... >(I'm sure I need to exchange Field1 with my actual field name but what about ... necessarily the same as the name of the subform). ... because the coding gets a little more complicated. ... John Nurick ...
    (microsoft.public.access.externaldata)
  • Re: Dlookup repeat
    ... To work properly in the subform context, the criteria of your ... DLookup function needs to reference the value in the subform, ... the total amount of hours and the employee ID. ... FROM Employees INNER JOIN Schedule ON Employees.= Schedule. ...
    (microsoft.public.access.gettingstarted)
  • Re: DLookup: error 2427 - expression that has no value
    ... It appeared that the filter being on caused an issue with the dlookup ... and block the new entry by cancelling its BeforeInsert ... I created VB code that filters a subform, which is based off of table [tbl ...
    (microsoft.public.access.modulesdaovba)