473,396 Members | 2,061 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,396 software developers and data experts.

Access Form Null Checking with Linked SQL / ODBC Table

I have a access form that is connected to linked sql table via odbc.
I have some fields that I dont want to allow nulls when data is
entered via the form. I can set the null checking on the SQL server
database but the ODBC error tha tis returned is not very polite to the
user since it mentions the sql field not the nice label.

Is there a way for me to modify this error or put the check in access?
Nov 13 '05 #1
4 2536
Try using the Form_BeforeUpdate Event to validate the data before actual
saving to the SQL Server.

--
HTH
Van T. Dinh
MVP (Access)


"Rich" <td*******@yahoo.com> wrote in message
news:22**************************@posting.google.c om...
I have a access form that is connected to linked sql table via odbc.
I have some fields that I dont want to allow nulls when data is
entered via the form. I can set the null checking on the SQL server
database but the ODBC error tha tis returned is not very polite to the
user since it mentions the sql field not the nice label.

Is there a way for me to modify this error or put the check in access?

Nov 13 '05 #2
This leads me to another question. What is the syntax frequired for
the before event? I searched around and found some validation code.
It has an It statment and msgbox command to post a message if the
validation fales however access doesnt like that code. It says that
the msgbox command has bad syntax.

What is the proper syntax for the validation event?
"Van T. Dinh" <Va***********@discussions.microsoft.com> wrote in message news:<e9*************@TK2MSFTNGP14.phx.gbl>...
Try using the Form_BeforeUpdate Event to validate the data before actual
saving to the SQL Server.

--
HTH
Van T. Dinh
MVP (Access)


"Rich" <td*******@yahoo.com> wrote in message
news:22**************************@posting.google.c om...
I have a access form that is connected to linked sql table via odbc.
I have some fields that I dont want to allow nulls when data is
entered via the form. I can set the null checking on the SQL server
database but the ODBC error tha tis returned is not very polite to the
user since it mentions the sql field not the nice label.

Is there a way for me to modify this error or put the check in access?

Nov 13 '05 #3
If you are talking about the BeforeUpdate Event, it is an Event Procedure
normally written in VBA code. Check Access VB Help on the BeforeUpdate
Event / Event Procedure. I think there are sample code in the Help topic.

If you are asking about the MsgBox statement, see Access VB Help on MsgBox.

In fact for syntax questions, you should always check Access Help first and
try rather than asking the newsgroups. If you can't get it to work after
checking Help, post the codes of your attempts with your question.

--
HTH
Van T. Dinh
MVP (Access)


"Rich" <td*******@yahoo.com> wrote in message
news:22**************************@posting.google.c om...
This leads me to another question. What is the syntax frequired for
the before event? I searched around and found some validation code.
It has an It statment and msgbox command to post a message if the
validation fales however access doesnt like that code. It says that
the msgbox command has bad syntax.

What is the proper syntax for the validation event?

Nov 13 '05 #4
You might as well just code the solution....

I put in the forms before update:

Cancel = MyVerify
And, my code for MyVerify is:
Private Function MyVerify() As Boolean

Dim colFields As New Collection

MyVerify = False

colFields.Add "Description,Description"
colFields.Add "City,City"
colFields.Add "cboProvince,Province"
colFields.Add "StartDate,Start date"
colFields.Add "EndDate,end date"
colFields.Add "AccountNo,Account number"

MyVerify = vfields(colFields)
End Function

Private Function vfields(colFields As Collection) As Boolean

Dim strErrorText As String
Dim strControl As String
Dim i As Integer

vfields = False

For i = 1 To colFields.Count
strControl = Split(colFields(i), ",")(0)
strErrorText = Split(colFields(i), ",")(1)
If IsNull(Me(strControl)) = True Then

MsgBox strErrorText & " is required", vbExclamation, AppName
Me(strControl).SetFocus
vfields = True
Exit Function
End If
Next i
End Function

Eg:
colFields.Add "AccountNo,Account number"

The first part is the control on the screen that we want to validate, and
the 2nd part of the custom "text" message that the user will get:

I paste the above into most screens, and thus I don't have to write a bunch
of code for each control that I want as requited. If the control is null,
then you get a error message, the cursor is also placed on the actual
control that is empty....
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl*****************@msn.com
http://www.attcanada.net/~kallal.msn
Nov 13 '05 #5

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

Similar topics

1
by: E. Zorn | last post by:
Hi, i use Access as a frontend via ODBC to an Linux-based postgresql. I have a problem in a form where I use a lot of subforms. In some cases ( i couldn't detect when - but I really try to) the...
0
by: LesM | last post by:
This is a change of behaviour between Access 2000 SP3 and Access 2002 SP3. I have Progress table that is linked via ODBC into Access using OpenLink Lite for Progress 9.0b. For over a year, using...
49
by: Yannick Turgeon | last post by:
Hello, We are in the process of examining our current main application. We have to do some major changes and, in the process, are questionning/validating the use of MS Access as front-end. The...
6
by: fumanchu | last post by:
I've got to let end users (really just one person) load billing batch files into a third party app table. They need to specify the billing cycle name, the batch name, and the input file name and...
10
by: Eric E | last post by:
Hi all, I am using an Access client linked to a PG 7.4 server via ODBC. I have a stored proc on the server that inserts rows into a table.particular table, accomplished via an INSERT within the...
52
by: Neil | last post by:
We are running an Access 2000 MDB with a SQL 7 back end. Our network guy is upgrading to Windows Server 2003 and wants to upgrade Office and SQL Server at the same time. We're moving to SQL Server...
2
by: egoldthwait | last post by:
I need to convert a 17mb access 2000 db to Oracle and house it in a Citrix farm. The issue: we have never converted an Access Db to Oracle but can probably use Oracle's Workbench to assist with...
6
by: onnodb | last post by:
Hi all, While working on an Access UI to a MySQL database (which should be a reasonable, low-cost, flexible interface to the DB, better than web-based, much less costly than a full-fledged .NET...
16
by: network-admin | last post by:
We have Problems with Access query on Oracle 10g Database with ODBC Connection. The Query_1 is such as select * from xtable where ycolumn <"S" Result = ODBC Faild...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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.