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

Add new record, requery to add to table and then open for returning to new record

I have a database where I want to add a new record to a form and then
send out an email based on the newly added information. I need to
requery the database so the appropriate information is included in the
database, so I want to add new record, requery once all information is
added.
The code I am currently using is
Dim myID As Variant
Dim rst As Recordset

If Me.Dirty Then
Me.Dirty = False
End If

myID = Me.Member_ID
Me.Refresh
Me.Requery

If IsNull(myID) Then
RunCommand acCmdRecordsGoToNew
Else
Set rs = Me.RecordsetClone
rs.FindFirst Member_ID = myID
If rs.noMatch Then
MsgBox "Member ID is no longer available"
Else
Me.Bookmark = rs.Bookmark
End If
End If

If Not Me.NewRecord Then
rs.Bookmark = Me.Bookmark
rs.MoveNext
If rs.EOF Then
MsgBox "You're at the last record"
End If
End If

Set rs = Nothing

End Sub

Nov 13 '05 #1
1 1661
Not sure exactly what you're trying to do here, but if you want to make
sure the current record is committed to the database before sending an
e-mail, why not just use;

DoCmd.RunCommand acCmdSaveRecord

This will commit the current record and you won't have to phutz around
with all that recordsetclone, refresh, requery stuff. Just launch
straight into your e-mail routine.

Nov 13 '05 #2

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

Similar topics

4
by: Skully Matjas | last post by:
I am using the following code (created by the wizard) to allow to bring my form to a particular entery. But when I edit the entery (ex: put new information into a blank cell), it puts that record...
3
by: Iain Miller | last post by:
I'm sure this ought to be simple but I can't make it work!! I have a form (based on a query) that holds information about an individual. Each individual has a Unique reference field called...
3
by: William Wisnieski | last post by:
Hello Everyone, Access 2000, I have a main unbound form with a bound datasheet subform . The subform is bound to a query that returns records based on criteria in the main form. The user...
4
by: Norm | last post by:
Hi All, When a table is linked to a form, Access normally updates the entire table when that record is closed. The fields don't get get updated in the table as they become changed. I've got...
4
by: amywolfie | last post by:
I've been trying to do something for about 3 days – I get close, but not 100%. I am trying to: Open frmRevisionHistory from a button on frmFeeInput. If there is NO RELATED RECORD, then I...
20
by: MS | last post by:
Access 97 I want to requery the data being displayed on a form, then I want to return to the record I was in. Why doesn't this code work? Private Sub CmdRefsh_Click()
22
by: Br | last post by:
First issue: When using ADPs you no longer have the ability to issue a me.refresh to save the current record on a form (the me.refresh does a requery in an ADP). We usually do this before...
6
by: jpatchak | last post by:
Hello, I have a main form with one subform. I have a command button on the main form to delete the current record. Below is my code. The tables on which the main form and subform are based...
10
by: sara | last post by:
Hi - I have been struggling with solution ideas for this now for almost 2 weeks, and have not been able to figure this out. I have a user who creates a Purchase Order (tblPOData). In some...
0
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,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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
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 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.