No match - Create a record

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form (RFP Form) where, when clicking a command button, it runs an
event procedure to pull up another form (Costing Form) with a matching
record. What I need to do is create a new Costing Form record if no matching
are found, and have it automatically pull the Project Title and Number from
the RFP Form.

My event procedure is currenlty as follows:

Private Sub cmdCost_Click()
On Error GoTo Err_cmdCost_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frm_Elite Costings"

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

Exit_cmdCost_Click:
Exit Sub

Err_cmdCost_Click:
MsgBox Err.Description
Resume Exit_cmdCost_Click

End Sub


I'm rather new, so any help is appreciated!!
 
Simplest Way is to set the default values of the Controls on the other form
If You're sure the form is only opened via the main form:
Control: [Project Title]
Default Value: =Forms![RPF Form]![Project Title]

HTH

Pieter

PS If I read you correctly you store Both ProjectNo & ProjectTitle in both
tables?. *Don't*
Store only the ProjectNo in the Child Table, Displaying the Title is easy
enough through Queries & Code




ddunks said:
I have a form (RFP Form) where, when clicking a command button, it runs an
event procedure to pull up another form (Costing Form) with a matching
record. What I need to do is create a new Costing Form record if no
matching
are found, and have it automatically pull the Project Title and Number
from
the RFP Form.

My event procedure is currenlty as follows:

Private Sub cmdCost_Click()
On Error GoTo Err_cmdCost_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frm_Elite Costings"

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

Exit_cmdCost_Click:
Exit Sub

Err_cmdCost_Click:
MsgBox Err.Description
Resume Exit_cmdCost_Click

End Sub


I'm rather new, so any help is appreciated!!
 

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

Back
Top