Go Back   Access World Forums > Apps and Windows > Excel

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 03-26-2019, 11:39 PM   #1
raghuprabhu
Newly Registered User
 
Join Date: Mar 2008
Posts: 154
Thanks: 43
Thanked 7 Times in 7 Posts
raghuprabhu is on a distinguished road
Open userform2 and register if the user is opening the workbook for the first time...

I have a work book with two worksheets. One is to input data “Sheet1” and other one to hold the details of the users “Sheet2”. It has two forms “Userform1” and ”Userform2”

When the user opens the workbook,

If the user is not in the “Sheet2” then
Open Userform2, input the users details
Save and close and open Userform1
Else
open Userform1
End if


Ps the form "Userform1" opens automatically. Click "Close" and then go from there..

I am trying to sort this and was finding it a bit tricky.

Thank you

Kind regards

Raghu
Attached Files
File Type: zip testing.zip (21.6 KB, 7 views)

raghuprabhu is offline   Reply With Quote
Old 03-27-2019, 12:13 AM   #2
Gasman
Enthusiastic Amateur
 
Join Date: Sep 2011
Location: Swansea, South Wales,UK
Posts: 3,605
Thanks: 388
Thanked 622 Times in 603 Posts
Gasman has a spectacular aura about Gasman has a spectacular aura about Gasman has a spectacular aura about
Re: Open userform2 and register if the user is opening the workbook for the first tim

In the Workbook_Open event
Check for user name in Sheet2. If not there open userform2
https://www.google.com/search?q=open...TF-8#kpvalbx=1

if there, then open userform1

I would perhaps add the user automatically and then open userform1, but I do nto know what else you want to store.?
I would probably hide Sheet2 as well?
__________________
Access novice. Sometimes trying to give something back.
Access 2007


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Last edited by Gasman; 03-29-2019 at 02:23 AM.
Gasman is online now   Reply With Quote
Old 03-29-2019, 12:07 AM   #3
raghuprabhu
Newly Registered User
 
Join Date: Mar 2008
Posts: 154
Thanks: 43
Thanked 7 Times in 7 Posts
raghuprabhu is on a distinguished road
Re: Open userform2 and register if the user is opening the workbook for the first tim

I have been been able to sort this out

Code:
Private Sub Workbook_Open()
On Error GoTo myErrorHandler:

Dim User_Name As String
Dim myRange As Range
Dim yesNo As Variant

Set myRange = Sheet2.Range("A:A")

User_Name = Environ("username")

yesNo = Application.WorksheetFunction.VLookup(User_Name, myRange, 1, False)

myErrorHandler:
    If Err.Number = 1004 Then
        UserForm2.Show
    Else
        UserForm1.Show
    End If
End Sub
Thank you

raghuprabhu is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Opening an Excel Workbook and Running a Macro from a Personal Macro Workbook MarkGallie Modules & VBA 6 07-11-2014 08:01 AM
Source workbook keeps opening when Destination workbook is protected??!?!?!? Virgo_Sam26 Excel 0 10-11-2012 08:32 AM
Opening a second workbook automatically Chris RR Excel 4 05-06-2009 04:59 AM
Opening Cash Register Draw soojosie General 1 06-18-2003 10:58 PM
Opening Excel Workbook ciao Modules & VBA 1 03-22-2002 03:48 PM




All times are GMT -8. The time now is 10:00 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World