Hi,
In one form, I have to click on button that opens the other form. Each form is bound to its table and those two tables are linked by Primary [RaDAR_Id] and Foreign [radar_id] fields. I would like the code to:
* open the other form
* move to the first record that has [radar_id] = [RaDAR_Is] if exists
If there is no any record in the other form that contains [radar_id] = [RaDAR_Id] then I want to create such record. So I am using the code (below). The problem is that the other form is not being updated. Please find the attached figure to see what I get. I don't know what i am doing wrong here. Thanks for any clues on that.
The link to the screenshot
In one form, I have to click on button that opens the other form. Each form is bound to its table and those two tables are linked by Primary [RaDAR_Id] and Foreign [radar_id] fields. I would like the code to:
* open the other form
* move to the first record that has [radar_id] = [RaDAR_Is] if exists
If there is no any record in the other form that contains [radar_id] = [RaDAR_Id] then I want to create such record. So I am using the code (below). The problem is that the other form is not being updated. Please find the attached figure to see what I get. I don't know what i am doing wrong here. Thanks for any clues on that.
Code:
Private Sub cmd_edit_usage_Click()
' DoCmd.OpenForm "frm_edit_usage"
Dim lngRadarId As Long
Dim patientId As Long
Dim rsUsage As DAO.Recordset
Dim rsUsageWrite As DAO.Recordset
lngRadarId = [Forms]![frm_main]![RaDAR_Id]
DoCmd.OpenForm "frm_edit_usage"
Set rsUsage = [Forms]![frm_edit_usage].RecordsetClone
rsUsage.FindFirst ("[radar_id]=" & CStr(lngRadarId))
If rsUsage.EOF Then
With [Forms]![frm_edit_usage]
Set rsUsageWrite = .Recordset
rsUsageWrite.AddNew
rsUsageWrite![RaDAR_Id] = lngRadarId
rsUsageWrite.Update
rsUsageWrite.Bookmark = rsUsageWrite.LastModified
rsUsageWrite.Close
Set rsUsageWrite = Nothing
End With
Else
[Forms]![frm_edit_usage].Bookmark = rsUsage.Bookmark
End If
Set rsUsage = Nothing
End Sub
The link to the screenshot