I need help with an Access form. When I use the code below, my unbound text box is being populated on all records of a form, instead of the one currently being used. How do I have the text box populated on only the current record? Thanks.
Private Sub Item_Budget_Name_ID_Change()
Dim rst As DAO.Recordset
Dim BudgetSingleAmount As Double
Dim SQL As String
SQL = "SELECT [Item Budget Single Amount] " & _
"FROM [Item Budget Amount Table] " & _
"WHERE [Item Budget Amount Table].[Month Name ID] = 16 " & _
"AND [Item Budget Amount Table].[Item Budget Name ID] = " & [Form_Test Internet Order Items Form].[Item Budget Name ID].Value & ";"
Set rst = CurrentDb.OpenRecordset(SQL)
BudgetSingleAmount = rst![Item Budget Single Amount]
rst.Close
Set rst = Nothing
[Form_Test Internet Order Items Form].[Item Budget Single Amount].Value = BudgetSingleAmount
End Sub
Private Sub Item_Budget_Name_ID_Change()
Dim rst As DAO.Recordset
Dim BudgetSingleAmount As Double
Dim SQL As String
SQL = "SELECT [Item Budget Single Amount] " & _
"FROM [Item Budget Amount Table] " & _
"WHERE [Item Budget Amount Table].[Month Name ID] = 16 " & _
"AND [Item Budget Amount Table].[Item Budget Name ID] = " & [Form_Test Internet Order Items Form].[Item Budget Name ID].Value & ";"
Set rst = CurrentDb.OpenRecordset(SQL)
BudgetSingleAmount = rst![Item Budget Single Amount]
rst.Close
Set rst = Nothing
[Form_Test Internet Order Items Form].[Item Budget Single Amount].Value = BudgetSingleAmount
End Sub