Copy from one form to another

johnbird1988

Board Regular
Joined
Oct 6, 2009
Messages
199
Hello

I would like to copy information from one form to another. I have been looking on the net for a while and cant get any thing to work.

I have a log In form called (LogInfrm) with Team Name (cboteamname) and Employee Name (cboEmployee) also with a password box and a button.

I then have another from which I would like the Team Name and Employee Name copied into. This form is called (Tesk Details) and the Team Name box (Text96) and a Employee Box (Text97).

I would like to information to copy when they have type the correct password in. I have copied the code for this below.

Thank you for your help

John

Code:
Private Sub Command4_Click()
'Check to see if data is entered into the UserName combo box
    If IsNull(Me.cboEmployee) Or Me.cboEmployee = "" Then
            MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
            Me.cboEmployee.SetFocus
        Exit Sub
    End If
'Check to see if data is entered into the password box
    If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
            MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
            Me.txtPassword.SetFocus
        Exit Sub
    End If
'Check value of password in tblEmployees to see if this matches value chosen in combo box
    If Me.txtPassword.Value = DLookup("Password", "Contacts", "[ID]=" & Me.cboEmployee.Value) Then
        lngMyEmpID = Me.cboEmployee.Value
'Close logon form and open splash screen
        
        DoCmd.Close acForm, "LogInfrm", acSaveNo
        DoCmd.OpenForm "Task Details"
        Else
        MsgBox "Password Invalid.  Please Try Again", vbOKOnly, "Invalid Entry!"
        Me.txtPassword.SetFocus
    End If
    
'If User Enters incorrect password 3 times database will shutdown
    
    intLogonAttempts = intLogonAttempts + 1
    If intLogonAttempts > 3 Then
        MsgBox "You do not have access to this database.  Please contact your system administrator.", vbCritical, "Restricted Access!"
        Application.Quit
    End If
End Sub
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
If the login form is the only way to the Tesk Details form, then simplest is to Hide (not close) the login form, and in Tesk Details your textboxes will just refer to it:

=[Forms]![LoginForm]![cboteamname]

Otherwise,
You can still do the same thing: Hide the login form (don't close it), open the Tesk Details form, set the textbox values, now close the login form...

Very rough and probably with syntax errors but something like:
Code:
Sub FOO()
LoginForm.Hide
DoCmd.OpenForm "Tesk_Details"
Forms![Tesk_Details]![Text96] = Forms![form_Login]![cboXXX1]
Forms![Tesk_Details]![Text97] = Forms![form_Login]![cboXXX2]
DoCmd.CloseForm "frm_Login"
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,858
Members
449,051
Latest member
excelquestion515

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top