473,769 Members | 8,283 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Ensuring non-null values in subdatasheet on record exit

Per
Hi,

I have a problem that I can't figure out. I have a database application
to keep track of boxes that contain files. For data entry, I have a
form with a main form section for the box-specific data (box
description etc), and a subform for entering details on each file
that's in the box (type, subtype etc). The subform is in a datasheet
form, with one record on each row.

Some of the subform fields are filled in using drop-downs, which have a
query on underlying tables as recordsource. Some of the fields (not
all) in the subform are required, ie Null is not allowed.

I want to check that all these required fields are filled in by the
user when he/she moves on to the next record in the subdatasheet. I
can't figure out how to do this. I have tried using the OnCurrent event
for the subform, cloning the current recordset, going back to the
previous record, and checking the values of these fields. But this
doesn't seem to work, it gets stuck in a loop betwen the last record
and the current record. Here's some code:
---
>From subform code:
Public currfile As Long
Public lastfile As Long
Public currbox As Long
Public lastbox As Long

Sub UpdateCurrentFi le()
If Not IsNull(Me.FileI D) And currfile <Me.FileID And currfile <0
Then
lastfile = currfile
End If
If Not IsNull(Me.FileI D) Then currfile = Me.FileID

If Not IsNull(Me.BoxID ) And currbox <Me.BoxID And currbox <0 Then
lastbox = currbox
End If
If Not IsNull(Me.BoxID ) Then currbox = Me.BoxID
End Sub
---
Private Sub Form_Current()
Dim strSQL As String
Dim choice As Integer
Dim rst As Recordset

UpdateCurrentFi le

If lastfile <0 Then
Set rst = Me.RecordsetClo ne
rst.FindFirst "FileID=" & lastfile
Me.Bookmark = rst.Bookmark

If IsNull(Me.DocTy pe) Then
MsgBox "DocType is required. Please select from drop-down box."
Me.DocType.SetF ocus
Me.DocType.Drop down
ElseIf IsNull(Me.Meeti ngType) And Me.DocType <"Election" Then
MsgBox "MeetingTyp e is required for this DocType. Please select
from drop-down box."
Me.MeetingType. SetFocus
Me.MeetingType. Dropdown
ElseIf IsNull(Me.SubTy pe) Then
MsgBox "SubType is required. Please select from drop-down box."
Me.SubType.SetF ocus
Me.SubType.Drop down
ElseIf IsNull(Me.Docum entDate) Then
MsgBox "DocumentDa te is required. Please select from drop-down
box."
Me.DocumentDate .SetFocus
Else
Me.Bookmark = Me.RecordsetClo ne.Bookmark
End If

rst.Close
Set rst = Nothing
Me.Refresh
End If
End Sub

I am using Access 2003, so the Access 2002 On Record Exit doesn't seem
to be avaiable. Any ideas?

Thanks for your help.

/Per

Aug 18 '06 #1
1 2358
On 18 Aug 2006 11:20:08 -0700, "Per" <pa**********@g mail.comwrote:

The proper event to perform the check is Form_BeforeUpda te of the
subform.
There is no need for a RecordsetClone; just access the values in the
various controls.

-Tom.

>Hi,

I have a problem that I can't figure out. I have a database application
to keep track of boxes that contain files. For data entry, I have a
form with a main form section for the box-specific data (box
description etc), and a subform for entering details on each file
that's in the box (type, subtype etc). The subform is in a datasheet
form, with one record on each row.

Some of the subform fields are filled in using drop-downs, which have a
query on underlying tables as recordsource. Some of the fields (not
all) in the subform are required, ie Null is not allowed.

I want to check that all these required fields are filled in by the
user when he/she moves on to the next record in the subdatasheet. I
can't figure out how to do this. I have tried using the OnCurrent event
for the subform, cloning the current recordset, going back to the
previous record, and checking the values of these fields. But this
doesn't seem to work, it gets stuck in a loop betwen the last record
and the current record. Here's some code:
---
>>From subform code:

Public currfile As Long
Public lastfile As Long
Public currbox As Long
Public lastbox As Long

Sub UpdateCurrentFi le()
If Not IsNull(Me.FileI D) And currfile <Me.FileID And currfile <0
Then
lastfile = currfile
End If
If Not IsNull(Me.FileI D) Then currfile = Me.FileID

If Not IsNull(Me.BoxID ) And currbox <Me.BoxID And currbox <0 Then
lastbox = currbox
End If
If Not IsNull(Me.BoxID ) Then currbox = Me.BoxID
End Sub
---
Private Sub Form_Current()
Dim strSQL As String
Dim choice As Integer
Dim rst As Recordset

UpdateCurrentFi le

If lastfile <0 Then
Set rst = Me.RecordsetClo ne
rst.FindFirst "FileID=" & lastfile
Me.Bookmark = rst.Bookmark

If IsNull(Me.DocTy pe) Then
MsgBox "DocType is required. Please select from drop-down box."
Me.DocType.SetF ocus
Me.DocType.Drop down
ElseIf IsNull(Me.Meeti ngType) And Me.DocType <"Election" Then
MsgBox "MeetingTyp e is required for this DocType. Please select
from drop-down box."
Me.MeetingType. SetFocus
Me.MeetingType. Dropdown
ElseIf IsNull(Me.SubTy pe) Then
MsgBox "SubType is required. Please select from drop-down box."
Me.SubType.SetF ocus
Me.SubType.Drop down
ElseIf IsNull(Me.Docum entDate) Then
MsgBox "DocumentDa te is required. Please select from drop-down
box."
Me.DocumentDate .SetFocus
Else
Me.Bookmark = Me.RecordsetClo ne.Bookmark
End If

rst.Close
Set rst = Nothing
Me.Refresh
End If
End Sub

I am using Access 2003, so the Access 2002 On Record Exit doesn't seem
to be avaiable. Any ideas?

Thanks for your help.

/Per
Aug 19 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
3753
by: klaus triendl | last post by:
hi, recently i discovered a memory leak in our code; after some investigation i could reduce it to the following problem: return objects of functions are handled as temporary objects, hence their dtor is called immediately and not at the end of the function. to be able to use return objects (to avoid copying) i often assign them to a const reference. now, casting a const return object from a function to a non-const reference to this...
3
12264
by: Mario | last post by:
Hello, I couldn't find a solution to the following problem (tried google and dejanews), maybe I'm using the wrong keywords? Is there a way to open a file (a linux fifo pipe actually) in nonblocking mode in c++? I did something ugly like --- c/c++ mixture --- mkfifo( "testpipe", 777);
2
1145
by: frs | last post by:
How can I get an 'always non-const equivalent' for the type "T" in the following example? Is there something like a 'non_const_cast' as in the code fragment below? template<typename T> class A { non_const_cast(T) x; };
3
1556
by: Peter Hardy | last post by:
Hi guys, Sorry for the cross-post but I got no response in the asp.net newsgroup. I am trying to develop a mini e-learning application where the user provides content for each page. Eventually, I'd like to shift to using templates but at the moment the users is just entering content using html. Whats the best way to allow the user to do this and whats the best way of ensuring the html is valid before I store it in my database / xml...
32
4526
by: Adrian Herscu | last post by:
Hi all, In which circumstances it is appropriate to declare methods as non-virtual? Thanx, Adrian.
0
840
by: Peter Hardy | last post by:
Hi guys, I am trying to develop a mini e-learning application where the user provides content for each page. Eventually, I'd like to shift to using templates but at the moment the users is just entering content using html. Whats the best way to allow the user to do this and whats the best way of ensuring the html is valid before I store it in my database / xml document? Cheers,
14
1576
by: ToddLMorgan | last post by:
Summary: How should multiple (related) projects be arranged (structured) and configured so that the following is possible: o Sharing common code (one of the projects would be a "common" project referenced by all others and likely the others would share at least the common project and possibly more as times goes on) o Clear separation of "production" code and "test" code (ie to readily ship source and test as separate components. Usually...
1
1705
by: Chris Curvey | last post by:
Hey all, I'm trying to write something that will "fail fast" if one of my users gives me non-latin-1 characters. So I tried this: u'\x80' I would have thought that that should have raised an error, because \x80 is not a valid character in latin-1 (according to what I can find). Is this the expected behavior, or am I missing something?
399
12938
by: =?UTF-8?B?Ik1hcnRpbiB2LiBMw7Z3aXMi?= | last post by:
PEP 1 specifies that PEP authors need to collect feedback from the community. As the author of PEP 3131, I'd like to encourage comments to the PEP included below, either here (comp.lang.python), or to python-3000@python.org In summary, this PEP proposes to allow non-ASCII letters as identifiers in Python. If the PEP is accepted, the following identifiers would also become valid as class, function, or variable names: Löffelstiel,...
3
1787
by: Josh Paetzel | last post by:
Is there a way to ensure that GNU readline isn't used (even though support may have been compiled in?). I'm experiencing a licensing problem, I'd like to use the "cmd" module, for example, but my code is proprietary and hence, if cmd uses readline, I can't use cmd. Unfortunately, I can't control if the Python interpreter my customers may be using has readline compiled in. So, I'm wondering if there is anyway to tell Python libraries like...
0
9589
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
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10219
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...
1
9998
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,...
1
7413
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5310
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
3967
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
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.