ivonsurf123
Registered User.
- Local time
- Today, 01:13
- Joined
- Dec 8, 2017
- Messages
- 69
Hello,
I am trying to bring two values in a txtfield from one form to another form using a combo box to select the option I want, then when populate the values I want to see but it is not the option I want I have a clear button that does not work, when I choose the option on the combo box and populates the values from the other form it records the data as soon it is populate, I do not want that, in case I choose the wrong option. need help please
code:
Private Sub cboGoToPosition_AfterUpdate()
On Error GoTo ErrHandler:
Dim str As String
str = cboGoToPosition.SelText
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
Me.REPLACEMENT_FOR = rsTemp![REPLACEMENT FOR]
Me.Position_Applied_For = rsTemp![POSITION NAME]
Else
Me.REPLACEMENT_FOR = ""
Me.Position_Applied_For = ""
End If
rsTemp.Close
Set rsTemp = Nothing
Set dbTemp = Nothing
Exit Sub
ErrHandler:
MsgBox Err.Description
End Sub
Private Sub cmdClearOpenPosition_Click()
Me.RecordSource = "SELECT tbl_GCDS_Operations_Positions_Recruit.* " & _
"FROM tbl_GCDS_Operations_Positions_Recruit " & _
"ORDER BY tbl_GCDS_Operations_Positions_Recruit.[Position Applied For];"
Me.Requery
Me.cboGoToPosition = ""
End Sub
I am trying to bring two values in a txtfield from one form to another form using a combo box to select the option I want, then when populate the values I want to see but it is not the option I want I have a clear button that does not work, when I choose the option on the combo box and populates the values from the other form it records the data as soon it is populate, I do not want that, in case I choose the wrong option. need help please
code:
Private Sub cboGoToPosition_AfterUpdate()
On Error GoTo ErrHandler:
Dim str As String
str = cboGoToPosition.SelText
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
Me.REPLACEMENT_FOR = rsTemp![REPLACEMENT FOR]
Me.Position_Applied_For = rsTemp![POSITION NAME]
Else
Me.REPLACEMENT_FOR = ""
Me.Position_Applied_For = ""
End If
rsTemp.Close
Set rsTemp = Nothing
Set dbTemp = Nothing
Exit Sub
ErrHandler:
MsgBox Err.Description
End Sub
Private Sub cmdClearOpenPosition_Click()
Me.RecordSource = "SELECT tbl_GCDS_Operations_Positions_Recruit.* " & _
"FROM tbl_GCDS_Operations_Positions_Recruit " & _
"ORDER BY tbl_GCDS_Operations_Positions_Recruit.[Position Applied For];"
Me.Requery
Me.cboGoToPosition = ""
End Sub