473,322 Members | 1,703 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,322 software developers and data experts.

How to open forms....

Hi All,

I have attached a small database (Access 2003). This has table to show customer details and order details.
It also has 3 forms and 2 subforms. The forms are as follows
frmAddNewCustomer is to input new customer
frmAddNewOrderDetails is to input new orderlines by customers
frmShowAllByCustNo which show the customers and the orders
In the table "tblCustInfo" I have three customers at present

ID IDNumber Surname GivenNames
1 2012001 Prabhu Raghu
2 2012002 Jain Sanjay
3 2012003 Kamath Sunil

In the table "tblPurOrder" I have the following data.
ID tblCustInfoID PurOrderNo purDate
1 1 201206001 1/06/2012
2 1 201206002 1/06/2012
3 2 201206003 1/06/2012
4 2 201206004 1/06/2012
when I open form frmShowAllByCustNo it prompts the user for the customer number. If I input 2012001 or 2012002 order lines will show.

If I input 2012003 there are no records to show.

My first question is

How do I make a message box popup and give the message "This customer does not have and order lines" and then the form "frmAddNewOrderDetails " popup when customer number 2012003 is input?

My second question is {Removed - Please check the rules}

Thanks

Raghu Prabhu
Attached Files
File Type: zip HowTo.zip (31.2 KB, 78 views)
Jun 2 '12 #1
3 1534
Someone who probably knows a little more than me might also be able to give you some advice, but this is what I would do in you situation. For both questions, I'd use the DCount function to determine if there are records that contain the value you entered.

For your first question (assuming you're typing the ID number in a textbox control called TxtBox), I'd use something like:

Expand|Select|Wrap|Line Numbers
  1. If DCount("*", "tblPurOrder", "[tblCustInfoID] = " & _
  2. DLookup("ID", "tblCustInfo", "[IDNumber] = " & Me.TxtBox)) = 0 Then
  3.  
  4. If MsgBox("The selected customer does not have any order lines. Would you like to add an order?", vbYesNo + vbQuestion) = vbYes Then
  5.  
  6. DoCmd.OpenForm "frmAddNewOrderLines", acNormal
  7.  
  8. Else   'No is selected
  9. Exit Sub
  10.  
  11. End If
  12.  
  13. Else   'If there are order lines
  14. DoCmd.OpenForm "frmShowAllByCustNo", acNormal
  15.  
  16. End If
For your second question, I'd pretty much use the same method (assuming that you're typing into TxtBox again):

Expand|Select|Wrap|Line Numbers
  1. If DCount("*", "tblCustInfo", "[IDNumber] = " & Me.TxtBox) = 0 Then
  2.  
  3. If MsgBox("This customer does not exist. Would you like to add this new customer now?", vbYesNo + vbQuestion) = vbYes Then
  4.  
  5. DoCmd.OpenForm "frmAddNewCust", acNormal
  6.  
  7. Else   'No is selected
  8. Exit Sub
  9.  
  10. End If
  11.  
  12. Else
  13. DoCmd.OpenForm ""   'You'll need to set this to what you want to open if the customer ID DOES exist.
  14.  
  15. End If
I think I pretty much get the gist of what you're asking, but I'm a little confused as to how your forms are set up. You can obviously tweak what I wrote to make it work for you, but it gives you a basic idea of one process you could potentially use.

Good luck!
Jun 2 '12 #2
@JenniferM
Thanks JenniferM will try. I was working along those lines too.
Jun 2 '12 #3
@JenniferM
Hi Jennifer,

I have attached a slightly different version. I put a form named frmMainMenu

When I input 2012001 or 2012002 the form "frmShowAllByCustNo" is showing which is good.

When I 2012003 it should open form "frmAddNewOrderDetails" and when I input 2012004 it should open form "frmAddNewCust"

It is not happening. Please look at my coding. I used what you supplied earlier.

Thanks

Raghu
Attached Files
File Type: zip HowToWithMainMenu.zip (26.0 KB, 86 views)
Jun 5 '12 #4

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

Similar topics

0
by: Kenny ODell | last post by:
When I click on a form, for instance Form1.H, the following error message pops up instead of the form: "An error occurred while loading the document. Fix the error, and then try loading the...
2
by: Rocky A | last post by:
This is my first posting so please be gentle I've been writing access programs for only about a year and may have bit off more than I can chew but....... I've written an operations program for...
1
by: petersk | last post by:
Firstly I am an older person trying to teach myself to create a project and teach myself Access VBA programming along the way. I anticipate a number of problems I will need help with but here...
2
by: Peter | last post by:
Hi I have an application that opens a new form displaying an alert for every new alert the system receives. The code is running on a timer in a separate thread and all the alert forms are...
2
by: js1300 | last post by:
Hello, I have a large project containing many forms and classes and even more instances of them. I'm looking for a way of listing all active instances in a project, i.e. all open forms and...
1
by: Bryan | last post by:
What are some of the methods you guys have used to update data in forms that has been changed by another open form? For example I might open an form to edit an employee, and when I close it I...
4
by: robert.waters | last post by:
Hello, I have a main form that is maximized when my application loads; this main form contains links to all other forms. I've had to specify the Popup property of these other forms, so that...
1
by: Daniel | last post by:
Hi I have a an application that opens up forms as it runs. So at any time 5 forms may be open for example, each form represents a room. I need a way to iterate through these forms so that...
4
by: nottarealaddress | last post by:
I'm trying to get my feet wet in VB2005 (our new standard at work after officially stopping new development in VB6 about a month ago). I'm working with a simple sql 2005 table of 50 entries, one...
2
by: Michael Burke | last post by:
Access 2007 Query - how to open forms in Datasheet View rather than Form View on a Switchboard. I need to change the code in the code element named "HandleButtenClick" Yet I cannot find this code...
0
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...
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.