From: Yappy on 28 May 2010 08:26 I have a combo box on it that searches for the record on my form. My problem is that when I enter a new record using my command button to add a new record, then try to search for another record on my form using my combo box, I get the following message: Error 2147352567 Update or CancelUpdate without AddNew or Edit I have the following code for my combo box: Private Sub cmbCoName_AfterUpdate() ' Find the record that matches the control. Dim rs As Object Set rs = Me.Recordset.Clone rs.FindFirst "[VendorNumber] = '" & Me![cmbCoName] & "'" If Not rs.EOF Then Me.Bookmark = rs.Bookmark End Sub This is what is highlighted in the code when I run the Debug: Me.Bookmark = rs.Bookmark When I close Access and reopen my database, only part of the new record I entered is there. How can I fix this? I am not good at VBA. I am using Access 2003. Thanks for your help.
From: Allen Browne on 28 May 2010 09:37 Try: Private Sub cmbCoName_AfterUpdate() ' Find the record that matches the control. Dim rs As DAO.Recordset Dim strWhere As String If Not IsNull(Me.cmbCoName) Then If Me.Dirty Then Me.Dirty = False Set rs = Me.Recordset.Clone strWhere = "[VendorNumber] = """ & Me![cmbCoName] & """" rs.FindFirst strWhere If rs.NoMatch Then MsgBox "Not found" Else Me.Bookmark = rs.Bookmark End If End If End Sub Explanation: http://allenbrowne.com/ser-03.html Note that if VendorNumber is a Number fields, you need to remove the extra quotes. -- Allen Browne - Microsoft MVP. Perth, Western Australia Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org. "Yappy" <Yappy(a)discussions.microsoft.com> wrote in message news:51105867-58F6-4130-A3AC-C11FD89F331C(a)microsoft.com... > I have a combo box on it that searches for the record on my form. My > problem > is that when I enter a new record using my command button to add a new > record, then try to search for another record on my form using my combo > box, > I get the following message: > Error 2147352567 > Update or CancelUpdate without AddNew or Edit > > I have the following code for my combo box: > > Private Sub cmbCoName_AfterUpdate() > ' Find the record that matches the control. > Dim rs As Object > > Set rs = Me.Recordset.Clone > rs.FindFirst "[VendorNumber] = '" & Me![cmbCoName] & "'" > If Not rs.EOF Then Me.Bookmark = rs.Bookmark > End Sub > > This is what is highlighted in the code when I run the Debug: > Me.Bookmark = rs.Bookmark > > When I close Access and reopen my database, only part of the new record I > entered is there. > > How can I fix this? I am not good at VBA. > > I am using Access 2003. > > Thanks for your help.
From: Yappy on 28 May 2010 10:24 Thanks, Allen. That seemed to help. I don't have any new records to add so I won't know for sure until then. Also, thanks for responding so quickly. I have seen other posts discussing that this very helpful discussion site is going to be shut down by Microsoft. I sure wish it wasn't true. This place has been very helpful to me. I will be sad to see it go. "Allen Browne" wrote: > Try: > > Private Sub cmbCoName_AfterUpdate() > ' Find the record that matches the control. > Dim rs As DAO.Recordset > Dim strWhere As String > > If Not IsNull(Me.cmbCoName) Then > If Me.Dirty Then Me.Dirty = False > Set rs = Me.Recordset.Clone > strWhere = "[VendorNumber] = """ & Me![cmbCoName] & """" > rs.FindFirst strWhere > If rs.NoMatch Then > MsgBox "Not found" > Else > Me.Bookmark = rs.Bookmark > End If > End If > End Sub > > Explanation: > http://allenbrowne.com/ser-03.html > > Note that if VendorNumber is a Number fields, you need to remove the extra > quotes. > > -- > Allen Browne - Microsoft MVP. Perth, Western Australia > Tips for Access users - http://allenbrowne.com/tips.html > Reply to group, rather than allenbrowne at mvps dot org. > > > "Yappy" <Yappy(a)discussions.microsoft.com> wrote in message > news:51105867-58F6-4130-A3AC-C11FD89F331C(a)microsoft.com... > > I have a combo box on it that searches for the record on my form. My > > problem > > is that when I enter a new record using my command button to add a new > > record, then try to search for another record on my form using my combo > > box, > > I get the following message: > > Error 2147352567 > > Update or CancelUpdate without AddNew or Edit > > > > I have the following code for my combo box: > > > > Private Sub cmbCoName_AfterUpdate() > > ' Find the record that matches the control. > > Dim rs As Object > > > > Set rs = Me.Recordset.Clone > > rs.FindFirst "[VendorNumber] = '" & Me![cmbCoName] & "'" > > If Not rs.EOF Then Me.Bookmark = rs.Bookmark > > End Sub > > > > This is what is highlighted in the code when I run the Debug: > > Me.Bookmark = rs.Bookmark > > > > When I close Access and reopen my database, only part of the new record I > > entered is there. > > > > How can I fix this? I am not good at VBA. > > > > I am using Access 2003. > > > > Thanks for your help. > > . >
|
Pages: 1 Prev: Export Table Records to txt file Next: Annoying Data Type Conversion Error |