473,722 Members | 2,338 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to open a form when database is opened based on a field value?

76 New Member
Hey guys. I'm writing a program and want to do the following.

I have a form for the company details called "companydetails ".
So when I open the database I want the form to display first if the "companynam e" fiel is empty. After filling in the form and clicked on "create" then it must take me to another form called "employeeen try" so that the first employee can be created. After all is done the databse shoul close and reopen and then display the form "login" so that the employee can login to the system. The rest is all set up to happen afterwards.

Thanks
Ryno
Jan 17 '11 #1
2 1429
TheSmileyCoder
2,322 Recognized Expert Moderator Top Contributor
Hi Ryno

I would create a blank form, call it "frm_StartU p". Then add an event procedure to the form's Load Event.
It could look something like this:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.   'Check if a company has been entered
  3.   if DCount("*","tbl_Company")>0 then
  4.     'There is at least 1 record in the table tbl_Company
  5.     if Dcount("*","tbl_Employee")>0 then
  6.       'There is at least 1 record in the table tbl_Employee
  7.       'Close this form, and open login form
  8.       Docmd.Close
  9.       docmd.OpenForm "frm_Login"
  10.     Else
  11.       'There is a company but no employee registered
  12.       'Close this form, and open Employee form
  13.       Docmd.Close
  14.       docmd.OpenForm "frm_Employee"
  15.     End If
  16.   Else
  17.     'No company registered, close this form,and open company form
  18.       Docmd.Close
  19.       Docmd.OpenForm "frm_Company"
  20.   End If
  21. End Sub
In your Company form, you should have code attached to your Create button that will check that a valid entry is made, and if so open the employee form in teh same manner as described above.

I hope this can get you started.

EDIT: Of course you need to set the datebase to always start by opening the frm_Startup, this can be done under database startup settings.
Jan 17 '11 #2
Ryno Bower
76 New Member
Thank you for the reply. Will try this and code around it if needed.
Jan 17 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2013
by: endran | last post by:
Hi Friends how to stop reopen form which already opened. for example my form code is like this every time when i click opening the form i want to stop that please help M.A.Endran Private Sub mnuRefSalesEXE_Click(ByVal sender As
4
3904
by: GavMc | last post by:
Hello I am new to internet programming and wonder if anyone can help me with this.... I am trying to pass a hidden field value on a form into another field on the form so that it can then be inserted in the database, to enable me then to reference that number at a later date. (The hidden value (1 for example) would then automatically get passed to the other input field.)
2
16799
by: surjs | last post by:
Hi I'm wanting some help on how to create a message that automatically pops up on opening an access form, that says for example ' Remember to ......'. I've been able to this by assigning a macro then a command button but need the message to be displayed as soon as the form is opened by the user. I'm using access 2003 - not an programming expert therefore would appreciate some simple instructions or a good website
1
3196
by: Tom | last post by:
hello i have 2 tables linked by a common id. The first table has records with a specific field with numeric values. eg 3 or 6 or 10 etc. What i want to happen is when i create a data entry form, i can scroll thru each record and when a value such as 6 comes along, the second/child table allows for 6 records to be created based on the same unique id using a data entry form eg table 1 id 6
3
2123
by: Rolan | last post by:
I need assistance regarding code needed to prevent someone from opening a form if a table field name(s) has been changed. For example, there is existing code to check for certain data based on DLookup in a table before a form can be opened. If one changes the field name in the table, then the verification check is bypassed. So adding code to DLookup to check for the existence of specific field names first is necessary. Any insight will be...
11
2001
by: MLH | last post by:
My alzheimer moments occur with greater frequency these days, it seems. I sometimes open Access and the same dbase in a second instance and work on items. If I modify a form and discover later that I'm working in a 2nd instance of Access, I close it. The modifications are not present in the first instance of the program and I have to make them again. Is there a setting I can make that will prevent me from inadvertently doing just that?
12
3056
by: insomniux | last post by:
Hi, In my database (access 2000) everything is done within the main form ("OpenForm"). It has a timer which triggers the code below. It first closes all reports and forms. Then it reopens the main form. When the main form is opened, the user is first asked for a password in a pop up window, which stores all kind of info in public variables. Problem is that quite often, the loginform makes access hang (a nonresponsive login form is...
2
1868
by: Les Desser | last post by:
We have a table (Table1) with a Long Integer field that is a key to an AutoNumber field on Table2 There is a 1-to-Many relationship from Table2 to Table1 on these fields. Table1 allows this field to be Null. An Auto-Form based on this table also accepted a null value for the field.
2
2064
by: Brave | last post by:
I'm hoping someone can help me with a small issue. I have an asp page that displays informaton from an Access database. I want to create a form that allows users to display only data that matches their search criteria. I have made many forms like this in Front Page with the Database results wizard, but I want to manually code it. Here is the code I use to display the data from a database.
3
1810
by: chuck gregory | last post by:
I'm using the 2002 (10.6771.6845) SP3 Access program. I have a form that will not show previously entered data. It has about 45 fields. I will call it the "parent" form. The "parent" form was at one time linked to another form, but I deleted the link since it is not needed. To troubleshoot it, I saved it with a new name, the "child" form. Then I created a table with two fields. I entered data in the two fields of the "child" form. I...
0
8863
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9384
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9157
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8052
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5995
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4502
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4762
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3207
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2602
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.