473,326 Members | 2,136 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

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

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 "companyname" fiel is empty. After filling in the form and clicked on "create" then it must take me to another form called "employeeentry" 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 1407
TheSmileyCoder
2,322 Expert Mod 2GB
Hi Ryno

I would create a blank form, call it "frm_StartUp". 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
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
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...
4
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...
2
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...
1
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...
3
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...
11
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...
12
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...
2
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...
2
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...
3
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.