"artworksdetails was opened from
a another form (in this instance all-cg-sorted-by-year-date) using a similar
method to open artworksdetails to display the full record. "
So you're saying the form artworksdetails is already open BEFORE you hit the
button you're trying to code? If so, that may be a problem. I don't think
that DoCmd line I gave you will work if the form is opened already.
If the form is NOT opened already, then I'd try renaming the control
(other>Record Number) on the artworksDetails to something like
txtRecordNumber, then modify my DoCmd line accordingly. Sometimes you get an
ambiguous reference when the control name is the same as the bound field.
If you have one form (call it formA) opening another (formB) and then you
are opening a third (formC) and trying to display records in formB based on
some field in formC, it sounds pretty confusing. If that's the case, I
consider coming up with a method that doesn't have three forms open at once
if possible.
Just to be clear, I'm not sure what the effect of having the form already
opened will have on the DoCmd line, but if it's not working and you try
changing the name of the control as instructed above, and it STILL doesn't
work, then that just about has to be the problem. I tested that line before
I made my original post this morning and I've used it many times before (I
just tested it to make sure the 'me' reference worked).
Hope something here helps.
CW
Krazy Darcy said:
yes, the button I am clicking on is in the main part of the artworksdetails
form which is displaying a populated record. artworksdetails was opened from
a another form (in this instance all-cg-sorted-by-year-date) using a similar
method to open artworksdetails to display the full record.
on art-use:
data> control source = record number
other> Name = record number
on artworksdetails:
data> control source = record number
other> Name = record number
record number is the keyfield for the main artworks table (which form
artworkdetails is tied to) record number is the relationship link between
the artworks table and the art-use table
:
Is your main form on an existing record when you click on the button to open
the other form?
Does the popup form control name [Record Number] happen to be the exact same
as the field it's bound to? (Read: 'name' on 'other' tab the same as
'control source' on 'data' tab)?
CW
:
I have even checked the case of the letters in the file and field names. The
button opens the form art-use but doesn't seem to fill in the record number
field in the art-use form.
It's as if it is behaving like it is wanting to display record(s) that has
the record number that is on the artworksdetails form (the form the button is
on)
thanks
:
Hi Darcy,
Just put that middle line of my code in the on_click event of the button you
are using to open the second form. Do that by opening your main form in
design view, clicking on the button, opening the properties window (f4),
clicking on the 'events' tab, and finding the "on click" event. Double click
in the text area beside the "on_click", and "event procedure" should fill the
blank area. Also, just to the right of that blank area, a button with "..."
on it will appear. Click that button (after you get the "event procedure" to
appear", and your form's vba module will appear with a new procedure opening
and closing lines already added. It will look like this:
Sub Private MyButtonName_Click()
End Sub
Between those lines goes my DoCmd....... line from my previous post.
Again, make sure the field names are correct in my line by checking the field
names on each form and comparing those with the names I used in that line.
Hope that helps,
CW
:
I cut/paste put that code in the expression builder (I think its called where
you can edit the vb code).
It opend the art-use form (I did add the - in the form name in the code as
the acxtual form has it in it's name). But it didn't fill the record number
field.
The art-use form is a seperate window not a embedded sub form.
:
Sub Private cmdOpenArtUse_Click()
DoCmd.OpenForm "Art Use", , , "[Record Number] = " & Me.[Record Number]
End Sub
I think that should work.
CW
:
Please could I have a "dummies guide" to opening subform with new record
using a value from another open form when I click on a button on that form.
I have searched the forums and couldn't figure out the various instructions
(I'm not a programmer/IT expert)
I have a form called Artworksdetails. On it is a field calle (without
quotes) "record number".
What I want is when I click on a button it opens the form called art-use on
a new record and pass the value in "record number" (in Artworksdetails) to
the field "record number" in art-use.
Apologies for what seems to be a common subject question but I need it
explained in "laymans terms"
Thank you for your patience.