rstOrder.nomatch is showing True when it should show False
Author |
Message |
Catherin #1 / 5
|
 rstOrder.nomatch is showing True when it should show False
I have this code working properly in other databases, but it isn't working correctly in the one I'm working on right now. When I step through the code, intOrderID obtains the number to correspond with the record I seek. When it moves to "If Not rstOrder.nomatch," however, it says that rstORder.nomatch = True. When I look at the underlying table, it should be False. I have checked the spelling of the field name on the form and on the table and I can't see why it is True instead of False. A match should be found. Please help me find the solution. THANKS! 'This seeks a specific customer order on a different form and takes the user to 'the correct record. It will allow access to all records, not just the one sought. Dim rstOrder As DAO.Recordset Dim frmOrder As Access.Form Dim intOrderID As Integer If IsNull(Me.txtName) Then MsgBox "Please choose an order to edit.", Title:="Edit Order" Exit Sub End If DoCmd.OpenForm "frmOrders" DoEvents Set frmOrder = Forms!frmOrders Set rstOrder = frmOrder.RecordsetClone intOrderID = Me.txtName.Column(1) rstOrder.FindFirst ("OrderID=" & intOrderID) If Not rstOrder.nomatch Then frmOrder.Bookmark = rstOrder.Bookmark End If Me.txtName = Null DoCmd.Close acForm, "frmFindOrder", acSaveNo Set frmOrder = Nothing Set rstOrder = Nothing intOrderID = 0 End Sub --Catherine
|
Sun, 04 Feb 2007 07:37:03 GMT |
|
 |
Allen Brown #2 / 5
|
 rstOrder.nomatch is showing True when it should show False
Suggestions: 1. The Column() property of a combo is zero-based. Did you mean: intOrderID = Me.txtName.Column(0) 2. If the form is filtered, the order may not be found. 3. Drop the DoEvents, which I think you added to give the form time to load its records. Instead, try this a few lines later: rstOrder.MoveLast That should force all the records to load. 4. You could also try without the parentheses: rstOrder.FindFirst "OrderID=" & intOrderID -- 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.
Quote: >I have this code working properly in other databases, but it isn't working > correctly in the one I'm working on right now. When I step through the > code, > intOrderID obtains the number to correspond with the record I seek. When > it > moves to "If Not rstOrder.nomatch," however, it says that rstORder.nomatch > = > True. When I look at the underlying table, it should be False. I have > checked > the spelling of the field name on the form and on the table and I can't > see > why it is True instead of False. A match should be found. Please help me > find > the solution. THANKS! > 'This seeks a specific customer order on a different form and takes the > user > to > 'the correct record. It will allow access to all records, not just the one > sought. > Dim rstOrder As DAO.Recordset > Dim frmOrder As Access.Form > Dim intOrderID As Integer > If IsNull(Me.txtName) Then > MsgBox "Please choose an order to edit.", Title:="Edit Order" > Exit Sub > End If > DoCmd.OpenForm "frmOrders" > DoEvents > Set frmOrder = Forms!frmOrders > Set rstOrder = frmOrder.RecordsetClone > intOrderID = Me.txtName.Column(1) > rstOrder.FindFirst ("OrderID=" & intOrderID) > If Not rstOrder.nomatch Then > frmOrder.Bookmark = rstOrder.Bookmark > End If > Me.txtName = Null > DoCmd.Close acForm, "frmFindOrder", acSaveNo > Set frmOrder = Nothing > Set rstOrder = Nothing > intOrderID = 0 > End Sub > --Catherine
|
Sun, 04 Feb 2007 10:15:53 GMT |
|
 |
Catherin #3 / 5
|
 rstOrder.nomatch is showing True when it should show False
Allen, Thank you for your suggestions. Before I got your response, I found a solution that also works. I may implement yours just to test them. In answer to your questions, I did reference the correct column (2nd column) remembering that combo boxes are zero-based. The form is not filtered. I will try the other two options for curiosity sake. The solution I found, that so far does not need to be implemented anywhere else I have this code snippet, is to open my form with DataMode:=acFormEdit. I honestly don't know why this form requires it when no other form requires it, but it seems to work now. THANK YOU for your suggestions! :-) --Catherine Quote:
> Suggestions: > 1. The Column() property of a combo is zero-based. > Did you mean: > intOrderID = Me.txtName.Column(0) > 2. If the form is filtered, the order may not be found. > 3. Drop the DoEvents, which I think you added to give the form time to load > its records. Instead, try this a few lines later: > rstOrder.MoveLast > That should force all the records to load. > 4. You could also try without the parentheses: > rstOrder.FindFirst "OrderID=" & intOrderID > -- > 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.
> >I have this code working properly in other databases, but it isn't working > > correctly in the one I'm working on right now. When I step through the > > code, > > intOrderID obtains the number to correspond with the record I seek. When > > it > > moves to "If Not rstOrder.nomatch," however, it says that rstORder.nomatch > > = > > True. When I look at the underlying table, it should be False. I have > > checked > > the spelling of the field name on the form and on the table and I can't > > see > > why it is True instead of False. A match should be found. Please help me > > find > > the solution. THANKS! > > 'This seeks a specific customer order on a different form and takes the > > user > > to > > 'the correct record. It will allow access to all records, not just the one > > sought. > > Dim rstOrder As DAO.Recordset > > Dim frmOrder As Access.Form > > Dim intOrderID As Integer > > If IsNull(Me.txtName) Then > > MsgBox "Please choose an order to edit.", Title:="Edit Order" > > Exit Sub > > End If > > DoCmd.OpenForm "frmOrders" > > DoEvents > > Set frmOrder = Forms!frmOrders > > Set rstOrder = frmOrder.RecordsetClone > > intOrderID = Me.txtName.Column(1) > > rstOrder.FindFirst ("OrderID=" & intOrderID) > > If Not rstOrder.nomatch Then > > frmOrder.Bookmark = rstOrder.Bookmark > > End If > > Me.txtName = Null > > DoCmd.Close acForm, "frmFindOrder", acSaveNo > > Set frmOrder = Nothing > > Set rstOrder = Nothing > > intOrderID = 0 > > End Sub > > --Catherine
|
Sun, 04 Feb 2007 11:23:01 GMT |
|
 |
Allen Brown #4 / 5
|
 rstOrder.nomatch is showing True when it should show False
Okay: your solution makes sense if the form's DataEntry property is set to No. In that case the form loads without any records, so the FindFirst fails. -- 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.
Quote: > Allen, > Thank you for your suggestions. Before I got your response, I found a > solution that also works. I may implement yours just to test them. > In answer to your questions, I did reference the correct column (2nd > column) > remembering that combo boxes are zero-based. The form is not filtered. I > will > try the other two options for curiosity sake. > The solution I found, that so far does not need to be implemented anywhere > else I have this code snippet, is to open my form with > DataMode:=acFormEdit. > I honestly don't know why this form requires it when no other form > requires > it, but it seems to work now. THANK YOU for your suggestions! :-) > --Catherine
>> Suggestions: >> 1. The Column() property of a combo is zero-based. >> Did you mean: >> intOrderID = Me.txtName.Column(0) >> 2. If the form is filtered, the order may not be found. >> 3. Drop the DoEvents, which I think you added to give the form time to >> load >> its records. Instead, try this a few lines later: >> rstOrder.MoveLast >> That should force all the records to load. >> 4. You could also try without the parentheses: >> rstOrder.FindFirst "OrderID=" & intOrderID >> -- >> 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.
>> >I have this code working properly in other databases, but it isn't >> >working >> > correctly in the one I'm working on right now. When I step through the >> > code, >> > intOrderID obtains the number to correspond with the record I seek. >> > When >> > it >> > moves to "If Not rstOrder.nomatch," however, it says that >> > rstORder.nomatch >> > = >> > True. When I look at the underlying table, it should be False. I have >> > checked >> > the spelling of the field name on the form and on the table and I can't >> > see >> > why it is True instead of False. A match should be found. Please help >> > me >> > find >> > the solution. THANKS! >> > 'This seeks a specific customer order on a different form and takes the >> > user >> > to >> > 'the correct record. It will allow access to all records, not just the >> > one >> > sought. >> > Dim rstOrder As DAO.Recordset >> > Dim frmOrder As Access.Form >> > Dim intOrderID As Integer >> > If IsNull(Me.txtName) Then >> > MsgBox "Please choose an order to edit.", Title:="Edit Order" >> > Exit Sub >> > End If >> > DoCmd.OpenForm "frmOrders" >> > DoEvents >> > Set frmOrder = Forms!frmOrders >> > Set rstOrder = frmOrder.RecordsetClone >> > intOrderID = Me.txtName.Column(1) >> > rstOrder.FindFirst ("OrderID=" & intOrderID) >> > If Not rstOrder.nomatch Then >> > frmOrder.Bookmark = rstOrder.Bookmark >> > End If >> > Me.txtName = Null >> > DoCmd.Close acForm, "frmFindOrder", acSaveNo >> > Set frmOrder = Nothing >> > Set rstOrder = Nothing >> > intOrderID = 0 >> > End Sub >> > --Catherine
|
Sun, 04 Feb 2007 12:00:08 GMT |
|
 |
Catherin #5 / 5
|
 rstOrder.nomatch is showing True when it should show False
Thank you, Allen. I admit, I thought that the Data Entry property should be set to Yes only if the end user will be doing Data Entry only, not if the end user wants to edit other records. I appreciate the explanation. :-) --Catherine :-) Quote:
> Okay: your solution makes sense if the form's DataEntry property is set to > No. In that case the form loads without any records, so the FindFirst fails. > -- > 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.
> > Allen, > > Thank you for your suggestions. Before I got your response, I found a > > solution that also works. I may implement yours just to test them. > > In answer to your questions, I did reference the correct column (2nd > > column) > > remembering that combo boxes are zero-based. The form is not filtered. I > > will > > try the other two options for curiosity sake. > > The solution I found, that so far does not need to be implemented anywhere > > else I have this code snippet, is to open my form with > > DataMode:=acFormEdit. > > I honestly don't know why this form requires it when no other form > > requires > > it, but it seems to work now. THANK YOU for your suggestions! :-) > > --Catherine
> >> Suggestions: > >> 1. The Column() property of a combo is zero-based. > >> Did you mean: > >> intOrderID = Me.txtName.Column(0) > >> 2. If the form is filtered, the order may not be found. > >> 3. Drop the DoEvents, which I think you added to give the form time to > >> load > >> its records. Instead, try this a few lines later: > >> rstOrder.MoveLast > >> That should force all the records to load. > >> 4. You could also try without the parentheses: > >> rstOrder.FindFirst "OrderID=" & intOrderID > >> -- > >> 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.
> >> >I have this code working properly in other databases, but it isn't > >> >working > >> > correctly in the one I'm working on right now. When I step through the > >> > code, > >> > intOrderID obtains the number to correspond with the record I seek. > >> > When > >> > it > >> > moves to "If Not rstOrder.nomatch," however, it says that > >> > rstORder.nomatch > >> > = > >> > True. When I look at the underlying table, it should be False. I have > >> > checked > >> > the spelling of the field name on the form and on the table and I can't > >> > see > >> > why it is True instead of False. A match should be found. Please help > >> > me > >> > find > >> > the solution. THANKS! > >> > 'This seeks a specific customer order on a different form and takes the > >> > user > >> > to > >> > 'the correct record. It will allow access to all records, not just the > >> > one > >> > sought. > >> > Dim rstOrder As DAO.Recordset > >> > Dim frmOrder As Access.Form > >> > Dim intOrderID As Integer > >> > If IsNull(Me.txtName) Then > >> > MsgBox "Please choose an order to edit.", Title:="Edit Order" > >> > Exit Sub > >> > End If > >> > DoCmd.OpenForm "frmOrders" > >> > DoEvents > >> > Set frmOrder = Forms!frmOrders > >> > Set rstOrder = frmOrder.RecordsetClone > >> > intOrderID = Me.txtName.Column(1) > >> > rstOrder.FindFirst ("OrderID=" & intOrderID) > >> > If Not rstOrder.nomatch Then > >> > frmOrder.Bookmark = rstOrder.Bookmark > >> > End If > >> > Me.txtName = Null > >> > DoCmd.Close acForm, "frmFindOrder", acSaveNo > >> > Set frmOrder = Nothing > >> > Set rstOrder = Nothing > >> > intOrderID = 0 > >> > End Sub > >> > --Catherine
|
Mon, 05 Feb 2007 02:27:02 GMT |
|
|
|