I have a project of 2 forms and on the 2nd form I want to create a button which when clicked returns you to the 1st form. Please help!

Create a button and the command button wizard will pop up. Go to the category, Form Operations and choose 'Open Form'. A list of your forms will appear/ and select the form you want it to go to when the button is clicked. Then you can write the text you want it to say on the button, like 'Back' and click, next and finish.

This won't close the current form so if you are familiar with VBA coding, go to the property bar, tab Event and click the 'On Click' button. This will take you to the code and if no code is currently under the button a Choose Builder menu will appear. Select 'Code Builder' and see below:

    'This will close the current form. Alternatively, Me.Visible = False
    DoCmd.Close

    'This will open the open you on click of the button
    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "The forms name"
    DoCmd.OpenForm stDocName, , , stLinkCriteria

Hope that helps :)

Edited 4 Years Ago by pyTony: fencing ~~~ vb code tags added

I have a project of 2 forms and on the 2nd form I want to create a button which when clicked, returns you to the 1st form and all values in the 3 textboxes disappear. Please help!

I have a project of 2 forms and on the 2nd form I want to create a button which when clicked, returns you to the 1st form and all values in the 3 textboxes disappear. Please help!

I don't get what you want exaclty.
You want get back from Form2 to Form1 but you not specify that both of forms active or not.
If both of forms active then just focus to form1 like ChrisPadgham said ( Form1.SetFocus ) and set textboxes to empty ( Textbox1.Text = "" ).
But if just form2 is currently active right now then call form1 again ( Form1.Show ) and Clear the textboxes.

Again, if you want help, post the code that you have already tried. The guidelines explicitly say that you are to submit a request with your attempts at writing code.

That being said you could use the hide and show methods for currently active forms:

frmFirst.Hide
frmSecond.Show

Edited 4 Years Ago by hkdani: n/a

Like what others have asked, I do not quite understand what you are trying to accomplish.
From my understanding you wish to open a form, say Form2, and then click the button on Form2, which returns your to Form1?
For that, here is code:

Private Sub CommandButton1_Click()
Me.Hide
UserForm1.Show
End Sub

What you will need to do is have 2 forms created;
1: UserForm1
2: UserForm2
Add a button to UserForm2, double click the button, and add the code above.

Regards
Gobble45

if you want to show form1 and form2 at a time
and now you want to close or just hide form2 and show first form1 again
Now you want when you close form2 then you form2 settings of the text boxes will cannot reset i mean when you open any time form2 you form2 all text boxes setting show previous same . so i hope help this

make a command botton and paste form1
Private Sub Command1_Click()
' show form2
Form2.Show
Form2.Left = 4860
End Sub

Private Sub Form_Load()

End Sub

make 2 command and 3 textbox botton in form 2 and paste this code

Private Sub Command1_Click()
' show form1 and form2 is goto left side beacause his settings will not change
' when you show again form2
Form1.Show
Me.Left = 17310

End Sub

Private Sub Command2_Click()
' if you want to reset all text boxs settings now you will use this botton
Unload Me
End Sub

' Note if you close your program then the setting will be changed
' other wise you will use registry setting
'getsetting

This article has been dead for over six months. Start a new discussion instead.