title: How can I populate textbox through VBA in MS Access?
body: <p>I have a table RR_info which hold following fields RR_ID, HR_ID, No_of_Beds, Room_Category. Now i want that through VBA code with Form_load event I should populate textboxes for all these table fields. For this I wrote a query which get certain records according to hotel_id as a criteria but code is not working.</p>
  <pre><code>Private Sub Form_Load()
  Dim SQL As String
  Dim db As Database
  Dim rs As DAO.Recordset
  
  SQL = &quot;select * from RR_info where hr_id = &quot; &amp; Forms![hhrrr]![List38] &amp; &quot;;&quot;
  Set db = CurrentDb
  Set rs = db.OpenRecordset(SQL)
  
  Me.RR_ID.Text = rs!RR_ID
  Me.HR_ID.Text = rs!HR_ID
  Me.Room_No.Text = rs![Room No]
  Me.No_of_Beds.text = rs!No_of_Beds
  Me.Room_Category.text = rs!Room_Category
  
  Set rs = Nothing
  Set db = Nothing
  
  End Sub
  </code></pre>
  <p><img src="https://i.stack.imgur.com/mlXAE.png" alt="enter image description here" /></p>
  <p>This is the Picture of Table in which I want to add table data according to criteria through VBA.</p>