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

form from query, how to throw an error?

118 100+
Hi folks,

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

SELECT *
FROM tblMembers
WHERE (((tblMembers.CustomerID)=Forms!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 1434
Jim Doherty
897 Expert 512MB
Hi folks,

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

SELECT *
FROM tblMembers
WHERE (((tblMembers.CustomerID)=Forms!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
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...
4
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...
25
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...
30
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...
0
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...
2
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...
8
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...
6
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...
1
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...

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.