Fairly new to VBA. I have a list box on a form within Access which is populated with data from a table. Selecting a value from the list box gives and ID which is then used to perform a query. I need this ID to be available for use in another form to perform a query based on the Value. What is the best way of achieving this?
`Dim IDValue As String
IDValue = Me.lstBoxCompanyName.Value
CompDetailSQL = "SELECT * FROM Companies WHERE Companies.CompanyID = " & IDValue`
Dim IDValue As StringChange it toPublic IDValue As Stringand place it in a module.Public IDValue As String. Then you would assign a value to the public variable like you would normally, but it will be available for all forms to use.