title: How can I pass a value from one form to another form in ms access
body: <p>I am just revising my request with detail code.
  I have a main data entry form.  Lets call it form1.  In form1 I have a text field name permit_number and a button get_permit_no.   To get permit numbers I have compare two tables and retrieve all possible numbers in the query.
  When I click get_permit_no, form2 will pop up with all possible permit numbers. Form2 is using query as record source.</p>
  
  <p><a href="https://i.stack.imgur.com/xQ1RA.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xQ1RA.jpg" alt="this is form2"></a></p>
  
  <p>Then user can select any number by clicking in the check box. Then when user click select permit number button i want to pass that value to form1.permit_number.  For example if user select 79959901,77994803 then i want to pass the whole string to form1.permit_number.</p>
  
  <p>Here is my code.</p>
  
  <pre><code>Public Sub CmdInsertPermitno_Click()
      DoCmd.RunCommand acCmdSaveRecord
  
      Dim rs As DAO.Recordset
      Dim strSQL
      strSQL = "Select permitno from query3 where check =" &amp; -1
  
      Set rs = CurrentDb.OpenRecordset(strSQL)
      Dim pno As String
      Dim getpno As String
  
      getpno = ""
  
      With rs
          If Not .BOF And Not .EOF Then
              .MoveLast
              .MoveFirst
  
              While (Not .EOF)
                  pno = rs.Fields("[permitno]")
                   .MoveNext
                  getpno = getpno &amp; "," &amp; pno
  
              Wend
          End If
      End With
  
      Set rs = Nothing
              getpermitno = Right(getpno, Len(getpno) - 1)
  
      DoCmd.OpenForm "Data Entry", acNormal, , , , acWindowNormal, OpenArgs:="getpermitno"
  
  End Sub
  </code></pre>
  
  <p>First I need to go back to form1 as last opening record place.  Then I want to pass the value.  </p>
  
  <p>Thanks,
  Htet</p>