Filtering One form from 2 fields of another

C

Chip

Howdy Again from Oklahoma!

I am really new to ACCESS and VB and I am having a problem opening the form
"frm_SavAction1" from an open form "frm_SAV" and filtering by 2 fields, one
field is on the form and the other field "savtext" is declared in the VB
script. I have had 2 other friends trying to help me but all i get is
confused and further from what i need.

Below is the script from the Event. I was told by a freind that a Run-time
error '2501' is received when you go to a form that the table does not have
an instance of a record with the criteria of the filter (Basically, I was
told that if the filter is trying to create a new record with the filter
criteria then you receive the error "2501" and that i needed to "Handle"
this error with the script to give a new record instead of the error
message) I am not sure my friends are pointing in the correct direction so
i thought i would ask the experts for help. There may be an easier way
and/or my friends may be completely wrong!!!

PLEASE HELP IF POSSIBLE, I NEED TO HAVE THIS FINISHED BY MONDAY 4 APRIL
2005 OR I MAY BE LOOKING FOR ANOTHER JOB...

THANKS IN ADVANCE!!

Here is the script i am using that does not work:

Private Sub Frame277_Click()
On Error GoTo Err_Frame277_Click

If Me.Frame277 = "2" Then

Dim stDocName As String
Dim stLinkCriteria As String
Dim stLinkCriteria2 As String
Dim savtext As String
stDocName = "frm_SavAction1"
savtext = "Facility does not have Asbestos Survey and Abatement
Records"
stLinkCriteria = "([SAVDesc]=" & "'" & [savtext] & "') and ([savid] =" &
"'" & Me!SAVNUM & "')"
DoCmd.OpenForm stDocName, , , stLinkCriteria


End If


Exit Sub

Err_Frame277_Click:
If Err.Number = 2501 Then
MsgBox "I have entered the error handling."
DoCmd.OpenForm stDocName, , , stLinkCriteria2
DoCmd.GoToRecord , , acNewRec
Forms![frm_SAVaction1]![SAVDesc] = savtext
Forms![frm_SAVaction1]![SAVID] = Me!SAVNUM


Else

MsgBox Err.Description
Resume Exit_frame277_Click

End If
Exit_frame277_Click:
End Sub
 
J

Jeff Boyce

Back up a step, Chip.

You've described "how" you are trying to do something, but not "what" or
"why". If you leave out references to current forms, and to current code,
what are you trying to accomplish?
 
Top