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

How to code a MsgBox correctly

I am a surgeon and has made a database for my patient record keeping. I have got a form 'Basic History Examination Form' that should not be opened directly but through another form "Patient Biodata Form". For that, I put following code in on exit event of 1st control of form 'HistoryID'

Expand|Select|Wrap|Line Numbers
  1. Private Sub HistoryID_Exit(Cancel As Integer)
  2.   If IsNull(Me.PatientIDPicker) Then
  3.     MsgBox "Sorry...!" & vbCrLf & "You can not enter data directly into 'Basic History Examination Form'" & vbCrLf & "Please " & _
  4. "close form and attempt data entry through 'Patient Biodata Form'", vbInformation, "Wrong Data Entry Attempt"
  5.     Form.DataEntry = False
  6. Exit Sub
When I open the form directly and attempt to enter data, it responds with pre-defined msg correctly but when I close msgbox and try to close the form, msgbox appears again... when I close it for second time, it again re-appears and then on closing msgbox, it closes alongwith form....
In this code "PatientIDPicker is an unbound field on form that gets automatically with 'patientID' value when form is opened in a normal way. e.g through Patient Biodata form.
I am unable to figure out that where there is a problem..

Is there anybody to help me out
Jun 26 '13 #1
1 985
TheSmileyCoder
2,322 Expert Mod 2GB
I can't really see anything in your code that matches the scenario you describe. So maybe there is more code that we are not seeing here?


Why not try this instead?
In the OPEN event of your History form add the following:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Open(Cancel as Integer)
  2.   IF Screen.ActiveForm.Name<>"Patient Biodata Form" Then
  3.     Cancel=True
  4.     MsgBox "This form should be opened from the 'Patient Biodata Form'
  5.   End If
  6. End Sub
Jun 26 '13 #2

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

Similar topics

3
by: JT | last post by:
im trying to use the MsgBox function in the following to display an ASP MsgBox containing text retrieved from the db into a recordset <% set rsMessages= myRecordset msg_text =...
2
by: Mathew Hill | last post by:
I am a beginner to the more technical aspects of Microsoft Access (2000) and was wondering if any one can help. I have 3 buttons on a form which add, delete and search for a record. However, when I...
3
by: Melissa | last post by:
I have a sales report where the sales are grouped by district. The report is based on a query with criteria for sales date to get the sales in any specified date range. I have code in the Format...
192
by: Vortex Soft | last post by:
http://www.junglecreatures.com/ Try it and tell me what's happenning in the Microsoft Corporation. Notes: VB, C# are CLS compliant
3
by: kosta | last post by:
Hello! i have an sql query that works well (returns correct results) when used in access XP, but does not work from a program... other queries work as designed. the query is: SELECT P.ID,...
2
by: batatoon | last post by:
Hi, I could use some help with this because I've run out of ideas. I need to sort an arraylist containg objects of type TA, but so far no luck. Here's the code: Class TAList: ArrayList { ...
1
by: teddysnips | last post by:
I'm collaborating on a project with a colleague, sharing files through SourceSafe. So, I run GetLatestVersion and suddenly I have 264 build errors - all "Unexpected character" The file in...
4
by: Craggy | last post by:
Hi, I am trying to pop up a yes/no message box so that a user can delete a record in a continuous form. The default delete message is a bit sloppy because it seems to move the continuous form to...
2
by: wassimdaccache | last post by:
Dear all I am using office 2007 SP2 I am trying to write a message box. msgbox "هل تريد حفظ هذه المعلومات ؟",vbYesNo Everything is OK but I am getting unknown symbole in place of the...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
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...

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.