Originally posted by YUPAPA
What I am trying to do is that when a user checks the box, it will run the SQL statement. The SQL statement is to select the address from a table, then set it to a textbox's value.
Bascially the checkbox is to ask the user if he wants to fill out the address with the one stored in the 'profile' table.
I understand that the code is incomplete. What I am trying to do is to solve the Dim Db As Database problem first and then perform Db.Execute strSQL.
Sorry I am VERY new to VB & Access
No need to apologise, this is a place for all to learn, newbies and oldies.
I would suggest that you use ADO.
You could try this:
Private Sub Check44_Click()
Dim myDb as ADODB.Connection
Dim myRS as ADODB.Recordset
Dim sSQL as String
Set myDb = CurrentProject.Connection
Set myRS = New ADODB.Recordset
sSQL = "SELECT * FROM Profile WHERE myFieldName = " & Me.myControl
myRS.Open sSQL, myDb
' move table fields to form controls
Me.txtStreetNo = myRS!StreetNo
Me.txtStreetName = myRS!StreetName
Set myRS = Nothing
Set myDb = Nothing
Difficult to give you full example of code without table, field, form and control names, but have a look at the above and see how you go.
I only have Access2000 so sending me a copy of your database, unless you can save it as Access2000 version.