i have been using this code to save my unbound form data into the table.
if no data has been entered and the save button is pressed a MSG box should be shown but i am getting an error 13
plz help me out -
Private Sub Save_Enter()
-
-
If (Me!Text0.Name And Me!Text2.Name = Null) Then
-
MsgBox "This record is blank. Please Enter something to save" _
-
, vbInformation, "Invalid Action"
-
Exit Sub
-
Else
-
Dim strQry As String
-
-
strQry = "INSERT INTO [Table1] ([voc_no],[name]) Values ('" & Me!Text0 & "','" & Me!Text2 & "')"
-
DoCmd.RunSQL strQry
-
End If
-
End Sub
-
7 1526
U dont check for null like u have, is IsNull instead
i.e.
If IsNull(Me.Text2) = True then
msgbox "Null field entered"
thanx a lot. i made a mistake.
when i press the save button the msg box saying that you are appending a record comes which is a default Msg in Access.
i dont want that to come instead i want that the msg defined by me should come.
this the code i am using.
plz help me out with it -
Private Sub Save_Enter()
-
-
If IsNull(Me.Text0) = True Then
-
MsgBox "This record is blank. Please Enter something to save" _
-
, vbInformation, "Invalid Action"
-
Exit Sub
-
Else
-
Dim strQry As String
-
-
strQry = "INSERT INTO [Table1] ([voc_no],[name]) Values ('" & Me!Text0 & "','" & Me!Text2 & "')"
-
DoCmd.RunSQL strQry
-
MsgBox "Do you want to save the record", vbOKOnly, "Alert"
-
End If
-
End Sub
-
This will turn off the warnings -
Private Sub Save_Enter()
-
DoCmd.SetWarnings False
-
If IsNull(Me.Text0) = True Then
-
MsgBox "This record is blank. Please Enter something to save" _
-
, vbInformation, "Invalid Action"
-
Exit Sub
-
Else
-
Dim strQry As String
-
-
strQry = "INSERT INTO [Table1] ([voc_no],[name]) Values ('" & Me!Text0 & "','" & Me!Text2 & "')"
-
DoCmd.RunSQL strQry
-
MsgBox "Do you want to save the record", vbOKOnly, "Alert"
-
End If
-
DoCmd.SetWarnings True
-
End Sub
-
This will turn off the warnings -
Private Sub Save_Enter()
-
DoCmd.SetWarnings False
-
If IsNull(Me.Text0) = True Then
-
MsgBox "This record is blank. Please Enter something to save" _
-
, vbInformation, "Invalid Action"
-
Exit Sub
-
Else
-
Dim strQry As String
-
-
strQry = "INSERT INTO [Table1] ([voc_no],[name]) Values ('" & Me!Text0 & "','" & Me!Text2 & "')"
-
DoCmd.RunSQL strQry
-
MsgBox "Do you want to save the record", vbOKOnly, "Alert"
-
End If
-
DoCmd.SetWarnings True
-
End Sub
-
hey thanx a lot that really worked.but instead of true i should be false.
thanx
hey thanx a lot that really worked.but instead of true i should be false.
thanx
You're welcome.
Hi Toral Shah, Im late in responding as usual!
Ok, Mary has given you one way, the other way to avoid those pesky message boxes is to use currentdb -
Private Sub Save_Enter()
-
-
Dim strQry As String
-
-
If IsNull(Me.Text0) = True Then
-
MsgBox "This record is blank. Please Enter something to save" _
-
, vbInformation, "Invalid Action"
-
Else
-
strQry = "INSERT INTO [Table1] ([voc_no],[name]) Values ('" & Me!Text0 & "','" & Me!Text2 & "')"
-
currentdb.execute strQry, dbFailOnError
-
End If
-
End Sub
-
Can I make a recommendation and u rename your textbox fields to something more meaningful
Text0 and Text2 and default names supplied by Access. Its more better to use your own names eg txtVocNo and txtName
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Jack |
last post by:
Hi,
I need to build a asp page where it would serve as a data entry record page
as well as display page for records saved. This page should also allow
editing of records that has been saved.
...
|
by: TheTenor |
last post by:
I have a page with a graphic. I want to be able to define the graphics such
that it is not saved when the viewer saves the page to his local drive. I'm
trying to avoid having a seperate folder...
|
by: CSDunn |
last post by:
Hello,
I have an Access 2000 Project in which the data comes from a SQL Server 2000
database, and multiple users need to be able to see new records as each user
adds records. The users also need...
|
by: Cillies |
last post by:
Hello all,
I was recently browsing the forum and remembered seeing a message
relating to MS Access Bugs/Flaws. The thing is I cannot find that
thread anymore, and so was wondering does anyone know...
|
by: Stuart McGraw |
last post by:
I haven't been able to figure this out and would
appreciate some help...
I have two tables, both with autonumber primary
keys, and linked in a conventional master-child
relationship. I've...
|
by: kaosyeti |
last post by:
i have a form that records 9 fields into a table. on that form i have a
'done' button to close the form. right now, if the form is fully filled in,
but you don't press 'enter' before you click...
|
by: John Kandell |
last post by:
Hi,
I posted this in the asp.net group, but didn't get a response. Maybe someone
here can help me with this...
---
Would someone be able to shed some light on what is the cost of saving a...
|
by: google |
last post by:
I have a form with several subforms. Users enter the data, then on the
parent there is a command button that runs code to generate a .pdf
document from a report based on the data they are working...
|
by: Andy_Khosravi |
last post by:
I'm having a problem with an entry form on one of my applications. It
would appear that the save action is sometimes not working, and is
generating no error when it fails. I'm hoping one of you may...
|
by: Cesar Zapata |
last post by:
Hi,
I have a a bound subform and what i'm trying to do is do check if some
criteria applies before saving the record and trigger a macro.
basically this is what I got.
Date Received ...
|
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,...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
|
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,...
|
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...
| |