Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Possible to Record a Macro in Access?

Status
Not open for further replies.

aprilmarie

Technical User
Apr 17, 2002
4
US
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top