A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Add a Duplicate Record



 
 
Thread Tools Display Modes
  #1  
Old March 26th, 2010, 11:43 AM posted to microsoft.public.access.forms
esee
external usenet poster
 
Posts: 14
Default Add a Duplicate Record

How do I add duplicate Bank Names with the events I am currently
using?

Private Sub combo68_AfterUpdate()
Dim rs As DAO.Recordset
If intRQ Then
Me.Requery
DoEvents
intRQ = False
End If
Set rs = Me.Recordset.Clone
' If BankID is a number here, do it this way:
rs.FindFirst "[BankID] = " & Me![Combo68]
' If BankID is text, then do it this way:
'rs.FindFirst "[BankID] = '" & Me!Combo68 & "'"
If rs.NoMatch Then
MsgBox "Record not found"
Else
Me.Bookmark = rs.Bookmark
End If
rs.Close
Set rs = Nothing

End Sub

Private Sub Combo68_NotInList(NewData As String, Response As Integer)
If vbYes = MsgBox("Do you want to add this NEW Bank?", vbYesNo)
Then
CurrentDb.Execute "INSERT INTO tblBanks(BankName) VALUES( """ &
NewData & """);", dbFailOnError
Response = acDataErrAdded ' Does an automatic requery of the
combo
' Tell after update that a Requery is needed for the new row
intRQ = True
Else
Response = acDataErrContinue
End If
End Sub
  #2  
Old March 26th, 2010, 02:47 PM posted to microsoft.public.access.forms
Jeff Boyce
external usenet poster
 
Posts: 8,621
Default Add a Duplicate Record

Why would you want more than one? Which one is the "right" one? How many
do you have to look for to find all of your data?

If you'll describe why you think you need "duplicate bank names", folks here
may be able to offer suggestions.

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.


"esee" wrote in message
...
How do I add duplicate Bank Names with the events I am currently
using?

Private Sub combo68_AfterUpdate()
Dim rs As DAO.Recordset
If intRQ Then
Me.Requery
DoEvents
intRQ = False
End If
Set rs = Me.Recordset.Clone
' If BankID is a number here, do it this way:
rs.FindFirst "[BankID] = " & Me![Combo68]
' If BankID is text, then do it this way:
'rs.FindFirst "[BankID] = '" & Me!Combo68 & "'"
If rs.NoMatch Then
MsgBox "Record not found"
Else
Me.Bookmark = rs.Bookmark
End If
rs.Close
Set rs = Nothing

End Sub

Private Sub Combo68_NotInList(NewData As String, Response As Integer)
If vbYes = MsgBox("Do you want to add this NEW Bank?", vbYesNo)
Then
CurrentDb.Execute "INSERT INTO tblBanks(BankName) VALUES( """ &
NewData & """);", dbFailOnError
Response = acDataErrAdded ' Does an automatic requery of the
combo
' Tell after update that a Requery is needed for the new row
intRQ = True
Else
Response = acDataErrContinue
End If
End Sub



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 12:20 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.