aprilmarie
Technical User
Does anyone know if I can record a macro in Access. If the answer is no. I have a list box that is populated with hours logged on a project, from one table. The value selected, (on the form) is to be stored in another table. However, if I don't click or tab to said field (list box with hours in it), it won't be saved. I am trying to make Access simulate a click in this list box. SetFocus and DoCmd.GoToControl ("lstHours" do not work. Please help.
The list box is populated with this code:
Option Compare Database
Option Explicit
Dim dbs As Database
Dim rst As Recordset
Private Sub cboTrainingProgID_Change()
Dim strSQL As String
Dim strID As String
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("Training Program ID"
Me.txtTrainingProgID.SetFocus
strID = Me.txtTrainingProgID.Text
With rst
'Populate Recordset.
.MoveLast
.MoveFirst
Do While True
strSQL = "SELECT [Training Program ID].[Hours] FROM [Training Program ID] WHERE [Training Program ID]. [TrainingProgID] = " & strID & ";"
DoCmd.GoToControl ("lstHours"
Me.lstHours.RowSource = strSQL
Exit Do
Loop
.Close
End With
dbs.Close
End Sub
The list box is populated with this code:
Option Compare Database
Option Explicit
Dim dbs As Database
Dim rst As Recordset
Private Sub cboTrainingProgID_Change()
Dim strSQL As String
Dim strID As String
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("Training Program ID"
Me.txtTrainingProgID.SetFocus
strID = Me.txtTrainingProgID.Text
With rst
'Populate Recordset.
.MoveLast
.MoveFirst
Do While True
strSQL = "SELECT [Training Program ID].[Hours] FROM [Training Program ID] WHERE [Training Program ID]. [TrainingProgID] = " & strID & ";"
DoCmd.GoToControl ("lstHours"
Me.lstHours.RowSource = strSQL
Exit Do
Loop
.Close
End With
dbs.Close
End Sub