473,480 Members | 2,057 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Inserting a record & adjusting form?

I'm trying to place an "ADD" button in a form to allow the user to add
records to a table. I'm using DAO. For some reason, the record gets
added, but the form doesn't point to it. In addition, the record
count doesn't seem to update on the screen.
===========================================
Private Sub bAdd_Click()
Dim strSQL As String
Dim rst As DAO.Recordset

strSQL = "Select * from Volunteers where NAME=""BLANK"""
Set rst = CurrentDb.OpenRecordset(strSQL)
rst.AddNew
rst.Update
rst.Bookmark = rst.LastModified
Me.Bookmark = rst.Bookmark
rst.Close
Set rst = Null
End Sub
============================================

Is there a simplier way to code this -- using DAO?
Nov 12 '05 #1
4 1278
There is nothing being added to the recordset! You have used AddNew and
Update consecutively, but have not set any field values in between - your
table may have some field requirements preventing the addition to the table.
If the user still has to enter the information, then the Update method has
to be invoked in a separate process. If the form is bound, then maybe just
use
DoCmd.GoToRecord acActiveDataObject, objectName, acNewRec ?

Mike Storr
www.veraccess.com
"Just Me" <z2****@hotmail.com> wrote in message
news:b9************************@posting.google.com ...
I'm trying to place an "ADD" button in a form to allow the user to add
records to a table. I'm using DAO. For some reason, the record gets
added, but the form doesn't point to it. In addition, the record
count doesn't seem to update on the screen.
===========================================
Private Sub bAdd_Click()
Dim strSQL As String
Dim rst As DAO.Recordset

strSQL = "Select * from Volunteers where NAME=""BLANK"""
Set rst = CurrentDb.OpenRecordset(strSQL)
rst.AddNew
rst.Update
rst.Bookmark = rst.LastModified
Me.Bookmark = rst.Bookmark
rst.Close
Set rst = Null
End Sub
============================================

Is there a simplier way to code this -- using DAO?

Nov 12 '05 #2
Mike -

There are defaults set on all the necessary fields. Any idea how I
make the newly created record into the currentRecord?
"Mike Storr" <no****@somewhere.con> wrote in message news:<35*******************@news20.bellglobal.com> ...
There is nothing being added to the recordset! You have used AddNew and
Update consecutively, but have not set any field values in between - your
table may have some field requirements preventing the addition to the table.
If the user still has to enter the information, then the Update method has
to be invoked in a separate process. If the form is bound, then maybe just
use
DoCmd.GoToRecord acActiveDataObject, objectName, acNewRec ?

Mike Storr
www.veraccess.com
"Just Me" <z2****@hotmail.com> wrote in message
news:b9************************@posting.google.com ...
I'm trying to place an "ADD" button in a form to allow the user to add
records to a table. I'm using DAO. For some reason, the record gets
added, but the form doesn't point to it. In addition, the record
count doesn't seem to update on the screen.
===========================================
Private Sub bAdd_Click()
Dim strSQL As String
Dim rst As DAO.Recordset

strSQL = "Select * from Volunteers where NAME=""BLANK"""
Set rst = CurrentDb.OpenRecordset(strSQL)
rst.AddNew
rst.Update
rst.Bookmark = rst.LastModified
Me.Bookmark = rst.Bookmark
rst.Close
Set rst = Null
End Sub
============================================

Is there a simplier way to code this -- using DAO?

Nov 12 '05 #3
On 13 Feb 2004 14:22:30 -0800, Just Me wrote:
Mike -

There are defaults set on all the necessary fields. Any idea how I
make the newly created record into the currentRecord?


The first thing I might try, is to do away with the SQL, and just use the
table name. Then, specify dbOpenDynaset for the type argument of
OpenRecordset. I'm wondering if you are creating a read-only rSet using
your current setup.

From the Access97 help files....
"Unlike dynaset- or snapshot-type Recordset objects, the table-type
Recordset object can't refer to more than one base table, and you can't
create it with an SQL statement that filters or sorts the data."

Which you are doing by using the WHERE statement.

--
Mike Storr
veraccess.com
Nov 12 '05 #4
If you use the Button wizard to add the button it will do most of it for
you. It won't automatically save the empty record but I'm not sure why
you would want that anyway.

Peter Russell

Just Me previously wrote:
I'm trying to place an "ADD" button in a form to allow the user to add
records to a table. I'm using DAO. For some reason, the record gets
added, but the form doesn't point to it. In addition, the record
count doesn't seem to update on the screen.
===========================================
Private Sub bAdd_Click()
Dim strSQL As String
Dim rst As DAO.Recordset

strSQL = "Select * from Volunteers where NAME=""BLANK"""
Set rst = CurrentDb.OpenRecordset(strSQL)
rst.AddNew
rst.Update
rst.Bookmark = rst.LastModified
Me.Bookmark = rst.Bookmark
rst.Close
Set rst = Null
End Sub
============================================

Is there a simplier way to code this -- using DAO?


Nov 12 '05 #5

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

Similar topics

1
3532
by: aegis | last post by:
page 45 "consider the function getbits(x,p,n) that returns the (right adjusted) n-bit field of x that begins at position p. We assume that bit position 0 is at the right end and that n and p are...
5
2008
by: bob44 | last post by:
Hi, I recently created a mysql database using phpmyadmin. I then proceeded to make a form to insert data into the database, but the problem is that the form is only able to insert one record, and...
1
1949
by: DanielLauJJ | last post by:
When inserting a record into a table, I want SQL Server to generate a number automatically for the Primary Key. (e.g. OrderID is 1, 2, 3 and so on) How to do it? (This behavior is similar to the...
2
3053
by: AlexanderDeLarge | last post by:
Hi! I got a problem that's driving me crazy and I'm desperately in need of help. I'll explain my scenario: I'm doing a database driven site for a band, I got these tables for their discography...
0
7048
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
6911
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
7050
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,...
1
6743
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
4488
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...
0
2999
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...
0
1303
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 ...
1
564
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
185
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...

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.