ivonsurf123
Registered User.
- Local time
- Yesterday, 23:46
- Joined
- Dec 8, 2017
- Messages
- 69
Hello,
Hopefully someone can help me with this problem, I an trying to add data in two fields on a subform call "B" from a subfrom call "A", but it 's no creating an "New" on ID field when I filter the data to be add it in subform "B" Please, help. Thank you.
Hopefully someone can help me with this problem, I an trying to add data in two fields on a subform call "B" from a subfrom call "A", but it 's no creating an "New" on ID field when I filter the data to be add it in subform "B" Please, help. Thank you.
Code:
Private Sub cboGoToPosition_AfterUpdate()
On Error GoTo ErrHandler:
Dim str As String
str = cboGoToPosition.SelText
Me.RecordSource = "SELECT tbl_GCDS_Operations_Positions_Recruit.* " & _
"From tbl_GCDS_Operations_Positions_Recruit " & _
"WHERE (((tbl_GCDS_Operations_Positions_Recruit.[Position Applied For])='" & Me.cboGoToPosition.Column(0, Me.cboGoToPosition.ListIndex) & "*" & Me.cboGoToPosition.Column(1, Me.cboGoToPosition.ListIndex) & "*')) " & _
"ORDER BY tbl_GCDS_Operations_Positions_Recruit.[Position Applied For];"
'Debug.Print Me.RecordSource
Me.Requery
Call cmdAdd_Click
Exit Sub
ErrHandler:
MsgBox Err.Description
End Sub
Code:
Private Sub cmdAdd_Click()
On Error GoTo ErrHandler
Dim str As String
str = Me.cboGoToPosition
Dim dbTemp As Database
Dim rsTemp As Recordset
'Open connection to current Access database and perform the search
Set dbTemp = CurrentDb()
Set rsTemp = dbTemp.OpenRecordset("SELECT [REPLACEMENT FOR],[Position Name] From tbl_GCDS_Operations_Positions_Fills " _
& "WHERE [REPLACEMENT FOR]= '" & str & "' and [Position Status] = 'Open'")
Me.RecordSource = "SELECT * " & _
"From tbl_GCDS_Operations_Positions_Recruit " & _
"WHERE ((([Position Applied For])='" & Me.cboGoToPosition.Column(0, Me.cboGoToPosition.ListIndex) & "')) " & _
"ORDER BY[Position Applied For];"
Me.Requery
'Update fields if data is found
If rsTemp.EOF = False Then
'rsTemp.AddNew
Me.Replacement_For = rsTemp![REPLACEMENT FOR]
Me.Position_Applied_For = rsTemp![POSITION NAME]
'rsTemp.Update
Else
Me.Replacement_For = ""
Me.Position_Applied_For = ""
End If
rsTemp.Close
Set rsTemp = Nothing
Set dbTemp = Nothing
Exit Sub
ErrHandler:
MsgBox "Couldn't create record", vbCritical
End Sub