So I have a form (Call Listing Subform) that is loaded hidden and is bound to a table as recordsource. A second unbound form (frmrepair) is used to enter data into the form subcalls.
Right now the code knows what record in Subcalls to add the data by reading the value of a field in another form.... This is the Call Listing Subform and the common field is CallID. I basically open the subcalls form, enter the data and close it to save it into the table.
This works fine. Now I need to open another form from frmrepair that is called frmestimate. frmestimate is bound to the table "tblrepdescription" which contains an autonumber, CallID and Description as fields.
On an "on-click" event in frmrepair I have the following code to open frmestimate
And in the "on open" event of frmestimate I have this code
On frmestimate I have a a field "Description" bound to the table tblredescription so when I enter info here, it is saved in tblrepdescription.
I have handle two situations:
1-If this is the first time that frmestimate is opened for this CallID, it will have no matching record in tblrepdescription, therefore the form needs to open in "New Record" mode and CallID needs to be entered in the appropiate field along with the text entered in the description field.
2-If there already is a record for this CallID in tbldescription, then frmestimate needs to open in Edit mode so that the description can be edited as I only want ONE description for each CallID.
Suggestions?
thanks
mafhobb
Code:
DoCmd.OpenForm "SubCalls"
[Forms]![SubCalls].Visible = False
[Forms]![SubCalls]![CallID] = Forms![contacts]![Call Listing Subform].Form![CallID].Value
[Forms]![SubCalls]![SubCallDate] = Now()
[Forms]![SubCalls]![WhoPickedUp] = sName
[Forms]![SubCalls]![WhatWasSaid] = Me.txtNewDetails.Value
[Forms]![SubCalls]![StatusAfterCall] = StatusAfterContact
[Forms]![SubCalls]![ResolutionDetails] = ResolutionValue
[Forms]![SubCalls]![Label] = ""
DoCmd.Close acForm, "SubCalls"
Right now the code knows what record in Subcalls to add the data by reading the value of a field in another form.... This is the Call Listing Subform and the common field is CallID. I basically open the subcalls form, enter the data and close it to save it into the table.
This works fine. Now I need to open another form from frmrepair that is called frmestimate. frmestimate is bound to the table "tblrepdescription" which contains an autonumber, CallID and Description as fields.
On an "on-click" event in frmrepair I have the following code to open frmestimate
Code:
Dim CallIDvar As String
Dim stDocName As String
Dim stLinkCriteria As String
CallIDvar = Forms![contacts]![Call Listing Subform].Form![CallID].Value
stDocName = "frmestimate"
MsgBox CallIDvar
stLinkCriteria = "[CallID]=" & CallIDvar
DoCmd.OpenForm stDocName, , , stLinkCriteria
And in the "on open" event of frmestimate I have this code
Code:
If Me.OpenArgs <> "" Then
MsgBox Me.OpenArgs
With Me.[frmEstimate].Form
.Filter = "[CallID]=" & Me.OpenArgs
.FilterOn = True
End With
End If
On frmestimate I have a a field "Description" bound to the table tblredescription so when I enter info here, it is saved in tblrepdescription.
I have handle two situations:
1-If this is the first time that frmestimate is opened for this CallID, it will have no matching record in tblrepdescription, therefore the form needs to open in "New Record" mode and CallID needs to be entered in the appropiate field along with the text entered in the description field.
2-If there already is a record for this CallID in tbldescription, then frmestimate needs to open in Edit mode so that the description can be edited as I only want ONE description for each CallID.
Suggestions?
thanks
mafhobb