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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|