Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open form command

Status
Not open for further replies.

GooGoocluster

Technical User
May 12, 2005
71
US
I am full of questions today...

I have a subform that is linked by the master Fieldname "project" what I want to do is use an entry form to creat new records with the "project" also linked here is the code I have. It works if the "Project" is already created. But I need it to display the ID even if its not created.

Code:

Private Sub AddJob2_Click()
On Error GoTo Err_AddJob2_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "InserterJobs entry"

stLinkCriteria = "[Project]=" & "'" & Me![Project] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_AddJob2_Click:
Exit Sub

Err_AddJob2_Click:
MsgBox Err.Description
Resume Exit_AddJob2_Click

End Sub
 
When I reread what I posted its unclear, So I will explain better.

The sub-form is displaying the current "project". I have a button on the same form which opens an entry form that displays the current "project" ONLY if that record has associated record with it. My table looks like this with sub-table under it:

[Project][Client]
Apples | Turkey
+ [Job][QTY]
app01 | 3500
Bannanas|Stuffing
Oranges |Pie
+ [Job][QTY]
org01|200
org02|4500

I hope you see what I am geeting at. Anyhow if i were to run my code the project "bannanas" would not show up because it has no sub-data. but the rest would I hope I made things clearer if not I can try again.

 
Totally baffled!

Are you trying to open a form for data entry based on the current record showing in the subform, only if the subform record has additional data associated with it?



Program Error
Programmers do it one finger at a time!
 
How are ya GooGoocluster . . . . .

[blue]Whats wrong with entering a new record on the subform itself?[/blue]

Calvin.gif
See Ya! . . . . . .
 
Ok I figured it out. Here is my solution.

I made an entry form with the parent projects information as a main form and then created a subform with subtable then linked them.

The problem I was having was the table I was using for the source did not have all of the records that my main table had. i.e.

Parent table: Project
Sub : Job

My subtable Job had a project feild also to tie them together. But only had data in that feild when there is a job that corrisponds with that project.

So when I was using the entry form with job and my source, when ever there was a Project that was not created in the job table. The entry form would have nothing in the project field. So if I made a new record it would have no parent.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top