Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old August 3rd, 2006, 11:36 AM
Spicoli Spicoli is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2006
Posts: 7 Spicoli User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 5 m 24 sec
Reputation Power: 0
Error Message

Hi everyone. Listen I creating a database in Access and I have developed a search engine in a form where the user types in a record number and then clicks on the search button which sends them to the correct record. However a problem that I'm currently having is when the user types in a wrong / non-existent record number the system sends the the user to blank form. I don't want it to do this, I would like it display an error message to the user. I'm trying to get the system to do this by running macro through the VBA. My code looks like this:


Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "ADMIN NUMBER calculate table Query"

stLinkCriteria = "[Admin Number]=" & "'" & Me![Find Admin Num] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

**If stLinkCriteria = "[Admin Number]<>" & "'" & Me![Find Admin Num] & "'" Then
Dim errormsg As String
errormsg = mcrConvertYourMacros_MSG2
End If**
'End Function
Exit_Command71_Button_Click:
Exit Sub

Err_Command71_Button_Click:
'If stLinkCriteria = "[Admin Number]<>" & "'" & Me![Find Admin Num] & "'" Then
'DoCmd.RunMacro(MSG2, [0], [0]) = stLinkCriteria
'End If
MsgBox Err.Description
Resume Exit_Command71_Button_Click

I have set off the part where I trying to get error message to come up in astrisks to help you view the code more clearly.


Could someone please help me?

Thanks,
Spicoli

Reply With Quote
  #2  
Old August 4th, 2006, 09:15 AM
sync_or_swim's Avatar
sync_or_swim sync_or_swim is online now
Moderator
Click here for more information.
 
Join Date: Mar 2006
Location: South Wales
Posts: 1,932 sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 6 Days 22 h 36 m 35 sec
Reputation Power: 1243
Hi,

I'm not sure what your Table/Field are called so you will have to amend the SQL statement accordingly, but try something like this to perform a select query first and if it retrieves a record then do your command, if not, display a message:
Code:
Dim stDocName As String
Dim stLinkCriteria As String
Dim db As Database
Dim strUserInput As String
strUserInput = InputBox("Please Enter an Admin Number")
Set db = CurrentDb
Dim rs As DAO.Recordset
Set rs = db.OpenRecordset("select * from YourTable where AdminNumber = '" & strUserInput & "'")
If ((rs.EOF = True) And (rs.BOF = True)) Then
     MsgBox ("No Record Found")
Else
     stDocName = "ADMIN NUMBER calculate table Query"
     stLinkCriteria = "[Admin Number]=" & "'" & Me![Find Admin Num] & "'"
     DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
rs.Close
End Sub

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > Error Message


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT