473,698 Members | 2,551 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

form from query, how to throw an error?

118 New Member
Hi folks,

I am making a solution to a problem using access, I have a query that is

SELECT *
FROM tblMembers
WHERE (((tblMembers.C ustomerID)=Form s!frmLogin![CID]));

I have then got a form (frmMembers) that loads the data from it.

frmLogin is just a text box (named CID) with a button that takes the user to the frmMembers with that. The data that is loaded is based on the input from frmLogin, if the user ID is either blank or does not exist it loads blank.

How would I do it that if the ID is either NULL or doesn't match any in tblMembers it returns an error message?

Hope that helps.

Sam
Jan 22 '08 #1
1 1508
Jim Doherty
897 Recognized Expert Contributor
Hi folks,

I am making a solution to a problem using access, I have a query that is

SELECT *
FROM tblMembers
WHERE (((tblMembers.C ustomerID)=Form s!frmLogin![CID]));

I have then got a form (frmMembers) that loads the data from it.

frmLogin is just a text box (named CID) with a button that takes the user to the frmMembers with that. The data that is loaded is based on the input from frmLogin, if the user ID is either blank or does not exist it loads blank.

How would I do it that if the ID is either NULL or doesn't match any in tblMembers it returns an error message?

Hope that helps.

Sam
Expand|Select|Wrap|Line Numbers
  1.  Dim Myval 
  2.  
  3. 'test for a null and convert to zero if encountered and if zero throw a message 
  4. IF NZ(Me!CID,0)=0 THEN
  5. DoCmd.Beep
  6. Msgbox "You must supply a value to login!",vbexclamation,"System Message"
  7. Exit sub
  8. 'otherwise we have a value entered so test it by counting on members for the number entered
  9. Else
  10. MyVal=DCount("[CustomerID]","tblMembers",[CustomerID="& Me!CID)
  11. End If
  12.  
'you got here so we have a number value we can test on. If its zero then no member exists

Expand|Select|Wrap|Line Numbers
  1.  IF MyVal =0 then 
  2. DoCmd.beep
  3. Msgbox "No Member exists having the number you supplied!",vbexclamation,"System Message"
  4. Exit Sub
  5. Else
  6. 'we have a number greater than zero so therefore a member (assuming no duplicates of course)
  7. Msgbox "Success a member does exist with that number so I am going to let you in! Have a nice day!
  8. ....your code then here to open the form
  9. End if
  10.  
I'm sure you can see the general principle of this if assigned to your command button.

Regards

Jim :)
Jan 22 '08 #2

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

Similar topics

12
6130
by: Pete..... | last post by:
Hi all. I have made a webpage where there is a webform where people can fill in their personel information: The code is below: I want to transfer the data to a postgreSQL database ( I have allready made the database with the neccesary tables, and I know how to connect to it ) but I really have no idea how I can transfer the data from the webform to
4
8970
by: Starbuck | last post by:
OK, first let me say that I am no DB person. But I have a user here who keeps getting this error whenever she does, whatever it is she does, with databases... A google search takes me to various forums where I am forced to sign up before I can read any answers. Interesting note here is that the guy in the office next
25
10241
by: Lyn | last post by:
Hi, I am working on a genealogy form. The only table (so far) lists everybody in the family, one record per person. Each record has an autonum ID. The parent form (frmMainForm) displays the data in each record, which includes the ID of the father and the mother (who also have records in the table). One record per form. I have a Tab Control in the form, and in one of the tabs I have a subform (sfmSiblings) in which I wish to list...
30
8900
by: Shannan Casteel via AccessMonster.com | last post by:
I have a subform named "sbfrmParts" with a list of parts along with the quantity and price. I have used a text box in the subform's footer and set the control source to "=Sum(*)". I set the format to display currency. This text box is called "SubformTotal", and is visible property is set to "No". On the main form I have made another text box and set its control source to "=.Form!SubformTotal". When I enter some parts everything works...
0
1852
by: fhiemstra0507 | last post by:
Hi I have a listbox that I want to update when the an item is updated/added. Now the listbox is attached to a query. Now I tried to just reload the query by modifying the forms loadDataSet and filldataset subroutines but when I do that the table values do not mesh which the lstbox anymore. As well, I have looked at the data adapters select statement to try and update it but to no avail. Any suggestions?
2
1584
by: Elliot Rodriguez | last post by:
I have a form that contains a mix of dynamic controls and declared controls. All of them are intrinsic .NET controls. Several functions within the page use Request.Form to query the value of the dynamic controls when the page is posted back. I also have a server side function that validates data ensuring it falls within a given range after the post back. If the range is not valid, I am Throw-ing a new Exception object; the validation...
8
14782
by: fonzie | last post by:
Is it possible to have a data entry form where the information is stored in several different tables (5 or 6)? I have an inventory database where Table1 stores all of the data common to all entries, Table2 stores only the extra info relevant to items that are TYPEA, Table3 stores only the extra info relevant to items that are TYPEB, and so on. All relationships are setup (one-to-one) between the main table (Table1) and all the other...
6
2900
by: martin DH | last post by:
**Urgent Need** I'll throw out the basics and any assistance is very, very, very much appreciated! Access 2003 on XP On a form (frmMain) is an option group of check boxes (ReportFrame) from which a user can choose a specific report to generate. The user selects the report of choice then presses a comand button (CmdRunRpt). The command button runs using the code below: Private Sub CmdRunRpt_Click() If ReportFrame = 1 Then...
1
2838
by: igor221189 | last post by:
Hello everyone. I have Access 2000 database which holds student records in the school.It stores subject grades for each student.In the 'Student Grade Form', I would like to search student surname using a query rather than scrolling down through 100s of names.Also, I would like the results of the query search to show in the form automatically in fields of 'Student name' and 'Student surname' based on the results.Is there any way I can do...
0
8680
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
9169
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...
0
9030
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8899
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
8871
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7738
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
4371
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...
1
3052
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
2335
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.