Hi,
I have a problem just executing a select statement. I want the value of a textbox to be determined by a simple select query.
I tried to use the Expression Builder but I don't know how to put arguments when using queries in it. For example, you want to select a field 'algemeenid' based on another field 'woningid'. If a query for this, named "selectionquery". Can anybody tell me how to do this?
Secondly, I tried to implement it as a visual basic function. I tried the following code, but it gives an error, and I don't know how to correct it.
This is the code
The error I get is a compile error "Expected Function or Variable". Could anyone please help? Any help on the syntax would be great.
I have a problem just executing a select statement. I want the value of a textbox to be determined by a simple select query.
I tried to use the Expression Builder but I don't know how to put arguments when using queries in it. For example, you want to select a field 'algemeenid' based on another field 'woningid'. If a query for this, named "selectionquery". Can anybody tell me how to do this?
Secondly, I tried to implement it as a visual basic function. I tried the following code, but it gives an error, and I don't know how to correct it.
This is the code
Code:
Private Sub Text25_Click()
Dim sql String
Dim rec As Recordset
sql = "SELECT algemeenid FROM woning WHERE woningid = 2;"
rec = DoCmd.OpenQuery(sql)
Text25 = rec
The error I get is a compile error "Expected Function or Variable". Could anyone please help? Any help on the syntax would be great.