Form Fields Not Showing For Linking

J

Jenna Baze

Hello - I'm wondering if anyone else has run into this problem, or knows how
to fix it.

When I attempt to use the command button wizard to create a button that
opens a form based on a foreign key.
I've been running into this repeatedly with other forms. I'm working on a db
that was created in Access 2003, and I'm using 2007 with it now. I'm not
sure if that is causing the problem.

Problem: In the "Which fields contain matching data..." screen where you can
link the two, the form that I am working on does not show any fields that I
can select.
When I do the coding in vba, it doesn't find the record. (This worked fine
previously.)

My code appears below. It runs properly as far as opening the form, but it
isn't recognizing the field and gives me a msgbox saying "There are no
matching records", which I've created on the frmProject if there are < 1
records in the recordset.

' Open project form, if it exists

If IsNull(Me.EstProjectNum) Then

Exit Sub

Else ' Is an project number

Dim stLinkCriteria As String
Dim stDocName As String

stDocName = "frmProject"

stLinkCriteria = "[ProjNum]=" & "'" & Me![EstProjectNum] & "'"
DoCmd.openForm stDocName, , , stLinkCriteria

End If

So, my main question is: how can I get the "Which fields contain matching
data..." dialog to go back to showing the fields on this form, instead of
being blank?

Thanks in advance for any advice.

SubyRuby
 
R

Rob Parker

Hi Jenna,

I'm a little confused by your post - I suspect because you're also a little
confused.

The "Which fields contain matching data..." dialog appears when you use the
wizard to add a subform to an existing form - generally to display the
"child" records for the parent record in the form. That doesn't seem to be
the case here. What you seem to be attempting to do is to open a separate
form (frmProject) and have it display those records that match the project
number of the current record in your existing form. The code you have
should be doing that.

The fact that it's not doing that, and that it displays your messagebox
saying there are no matching records, indicates a problem with frmProject.
Does it have a recordsource (a table or query), and does that recordsource
contain a field named ProjNum? If that's not the case, then frmProject can
never display what you are asking. If that is the case, then are you sure
that there is/are record(s) in the frmProject recordsource with ProjNum
equal to the value of EstProjectNum in the current record of your existing
form.

HTH,

Rob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top