|
|
Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
I am using this in other forms in the same frontend mdb and it works fine. In one form, however, it does not. I have tried the form's record source as both the a table and a query.
Anyone found a reason or solution for this? Thanks.
|
|
You'll have to tell us a lot more details about the form, where/when you're using this, how you're using this, etc. This error message usually shows up when (1) some other event is blocking the moving to another record; (2) an error exists in the programming that is running at that time; (3) your setup is not proper for using this action; etc.
--
Ken Snell <MS ACCESS MVP>
"Elaine" <Elaine[ at ]discussions.microsoft.com> wrote in message news:11013B2B-36B5-43ED-8BF3-4404D726111C[ at ]microsoft.com...
[Quoted Text] >I am using this in other forms in the same frontend mdb and it works fine. > In one form, however, it does not. I have tried the form's record source > as > both the a table and a query. > > Anyone found a reason or solution for this? Thanks.
|
|
Ken, It is one form (no sub forms). I have tried the record source being a table as well as a query. There is a combo box that selects records from the table in which I want to select the record. The user selects the record and in the on click of that field, the following code runs:
Private Sub SrchRec_Click() On Error GoTo Err_SrchRec_Clk GlbCBIDSrch = Empty GlbCBIDSrch = Me.SrchRec.Column(0) Dim Fnd As Variant Fnd = Me.SrchRec.Column(0) Forms![frmcbopen]![CmpltNum].SetFocus DoCmd.FindRecord Fnd
Forms![frmcbopen]![CmpltTyp].SetFocus
Exit_SrchRec_Clk: Exit Sub Err_SrchRec_Clk: ErrorMessage ("CBOpen Srch Record Click") Resume Exit_SrchRec_Clk End Sub This exact code used in the same manner works on other forms in this same mdb. There are 124 fields on the form and in the sql table which is more than in the other forms/tables. Aside from that, I see no differences.
I would prefer to us a query with a like statement looking at the primary field being equal to the field on the form. In that way the user does not have a record appearing until they select something. However, at this point, anything is ok if it works! (Note a bit of frustration going on... :) )
Thank you for your help, Elaine
"Ken Snell (MVP)" wrote:
[Quoted Text] > You'll have to tell us a lot more details about the form, where/when you're > using this, how you're using this, etc. This error message usually shows up > when (1) some other event is blocking the moving to another record; (2) an > error exists in the programming that is running at that time; (3) your setup > is not proper for using this action; etc. > > -- > > Ken Snell > <MS ACCESS MVP> > > > > "Elaine" <Elaine[ at ]discussions.microsoft.com> wrote in message > news:11013B2B-36B5-43ED-8BF3-4404D726111C[ at ]microsoft.com... > >I am using this in other forms in the same frontend mdb and it works fine. > > In one form, however, it does not. I have tried the form's record source > > as > > both the a table and a query. > > > > Anyone found a reason or solution for this? Thanks. > > >
|
|
I recommend using the AfterUpdate event of the combobox, not the Click event, to run search code.
Is CmpltNum the name of the form on which this combobox is located? Are you trying to search within the same form?
Is the combobox bound to a field in the form's recordsource table or query? Is that the field in which you want to find the selected value?
Assuming all answers are yes, here is the code that I recommend:
Private Sub SrchRec_AfterUpdate() If Len(Me.Srch.Rec.Column(0) & "") > 0 Then With Me.RecordsetClone .FindFirst Me.SrchRec.ControlSource & "=" & Me.Srch.Rec.Column(0) If .NoMatch = False Then Me.Bookmark = .Bookmark End With End If End Sub
The above assumes that the field to which the combo box is bound is a numeric field. If it's text or date type, then a slight change is needed in the code syntax -- but I'll not post that unless you indicate that the field is one of these.
Otherwise, using your FindRecord code, this should work:
Private Sub SrchRec_AfterUpdate() If Len(Me.Srch.Rec.Column(0) & "") > 0 Then DoCmd.FindRecord Me.Srch.Rec.Column(0) End If End Sub
--
Ken Snell <MS ACCESS MVP>
"Elaine" <Elaine[ at ]discussions.microsoft.com> wrote in message news:96EFBF2A-6467-4D92-B829-3E2E23447EBE[ at ]microsoft.com...
[Quoted Text] > Ken, > It is one form (no sub forms). I have tried the record source being a > table > as well as a query. There is a combo box that selects records from the > table > in which I want to select the record. The user selects the record and in > the > on click of that field, the following code runs: > > Private Sub SrchRec_Click() > On Error GoTo Err_SrchRec_Clk > GlbCBIDSrch = Empty > GlbCBIDSrch = Me.SrchRec.Column(0) > Dim Fnd As Variant > Fnd = Me.SrchRec.Column(0) > > Forms![frmcbopen]![CmpltNum].SetFocus > DoCmd.FindRecord Fnd > > Forms![frmcbopen]![CmpltTyp].SetFocus > > Exit_SrchRec_Clk: > Exit Sub > Err_SrchRec_Clk: > ErrorMessage ("CBOpen Srch Record Click") > Resume Exit_SrchRec_Clk > End Sub > This exact code used in the same manner works on other forms in this same > mdb. There are 124 fields on the form and in the sql table which is more > than in the other forms/tables. Aside from that, I see no differences. > > I would prefer to us a query with a like statement looking at the primary > field being equal to the field on the form. In that way the user does not > have a record appearing until they select something. However, at this > point, > anything is ok if it works! (Note a bit of frustration going on... :) ) > > Thank you for your help, Elaine > > > "Ken Snell (MVP)" wrote: > >> You'll have to tell us a lot more details about the form, where/when >> you're >> using this, how you're using this, etc. This error message usually shows >> up >> when (1) some other event is blocking the moving to another record; (2) >> an >> error exists in the programming that is running at that time; (3) your >> setup >> is not proper for using this action; etc. >> >> -- >> >> Ken Snell >> <MS ACCESS MVP> >> >> >> >> "Elaine" <Elaine[ at ]discussions.microsoft.com> wrote in message >> news:11013B2B-36B5-43ED-8BF3-4404D726111C[ at ]microsoft.com... >> >I am using this in other forms in the same frontend mdb and it works >> >fine. >> > In one form, however, it does not. I have tried the form's record >> > source >> > as >> > both the a table and a query. >> > >> > Anyone found a reason or solution for this? Thanks. >> >> >>
|
|
Sorry, typos in my codes:
Private Sub SrchRec_AfterUpdate() If Len(Me.Srch.Rec.Column(0) & "") > 0 Then With Me.RecordsetClone .FindFirst Me.SrchRec.ControlSource & "=" & Me.SrchRec.Column(0) If .NoMatch = False Then Me.Bookmark = .Bookmark End With End If End Sub
Private Sub SrchRec_AfterUpdate() If Len(Me.SrchRec.Column(0) & "") > 0 Then DoCmd.FindRecord Me.SrchRec.Column(0) End If End Sub
--
Ken Snell <MS ACCESS MVP>
"Ken Snell (MVP)" <kthsneisllis9[ at ]ncoomcastt.renaetl> wrote in message news:OfUFIjTyGHA.4232[ at ]TK2MSFTNGP04.phx.gbl...
[Quoted Text] >I recommend using the AfterUpdate event of the combobox, not the Click >event, to run search code. > > Is CmpltNum the name of the form on which this combobox is located? Are > you trying to search within the same form? > > Is the combobox bound to a field in the form's recordsource table or > query? Is that the field in which you want to find the selected value? > > Assuming all answers are yes, here is the code that I recommend: > > Private Sub SrchRec_AfterUpdate() > If Len(Me.Srch.Rec.Column(0) & "") > 0 Then > With Me.RecordsetClone > .FindFirst Me.SrchRec.ControlSource & "=" & Me.Srch.Rec.Column(0) > If .NoMatch = False Then Me.Bookmark = .Bookmark > End With > End If > End Sub > > The above assumes that the field to which the combo box is bound is a > numeric field. If it's text or date type, then a slight change is needed > in the code syntax -- but I'll not post that unless you indicate that the > field is one of these. > > Otherwise, using your FindRecord code, this should work: > > Private Sub SrchRec_AfterUpdate() > If Len(Me.Srch.Rec.Column(0) & "") > 0 Then > DoCmd.FindRecord Me.Srch.Rec.Column(0) > End If > End Sub > > > -- > > Ken Snell > <MS ACCESS MVP> > > "Elaine" <Elaine[ at ]discussions.microsoft.com> wrote in message > news:96EFBF2A-6467-4D92-B829-3E2E23447EBE[ at ]microsoft.com... >> Ken, >> It is one form (no sub forms). I have tried the record source being a >> table >> as well as a query. There is a combo box that selects records from the >> table >> in which I want to select the record. The user selects the record and in >> the >> on click of that field, the following code runs: >> >> Private Sub SrchRec_Click() >> On Error GoTo Err_SrchRec_Clk >> GlbCBIDSrch = Empty >> GlbCBIDSrch = Me.SrchRec.Column(0) >> Dim Fnd As Variant >> Fnd = Me.SrchRec.Column(0) >> >> Forms![frmcbopen]![CmpltNum].SetFocus >> DoCmd.FindRecord Fnd >> >> Forms![frmcbopen]![CmpltTyp].SetFocus >> >> Exit_SrchRec_Clk: >> Exit Sub >> Err_SrchRec_Clk: >> ErrorMessage ("CBOpen Srch Record Click") >> Resume Exit_SrchRec_Clk >> End Sub >> This exact code used in the same manner works on other forms in this same >> mdb. There are 124 fields on the form and in the sql table which is more >> than in the other forms/tables. Aside from that, I see no differences. >> >> I would prefer to us a query with a like statement looking at the primary >> field being equal to the field on the form. In that way the user does >> not >> have a record appearing until they select something. However, at this >> point, >> anything is ok if it works! (Note a bit of frustration going on... >> :) ) >> >> Thank you for your help, Elaine >> >> >> "Ken Snell (MVP)" wrote: >> >>> You'll have to tell us a lot more details about the form, where/when >>> you're >>> using this, how you're using this, etc. This error message usually shows >>> up >>> when (1) some other event is blocking the moving to another record; (2) >>> an >>> error exists in the programming that is running at that time; (3) your >>> setup >>> is not proper for using this action; etc. >>> >>> -- >>> >>> Ken Snell >>> <MS ACCESS MVP> >>> >>> >>> >>> "Elaine" <Elaine[ at ]discussions.microsoft.com> wrote in message >>> news:11013B2B-36B5-43ED-8BF3-4404D726111C[ at ]microsoft.com... >>> >I am using this in other forms in the same frontend mdb and it works >>> >fine. >>> > In one form, however, it does not. I have tried the form's record >>> > source >>> > as >>> > both the a table and a query. >>> > >>> > Anyone found a reason or solution for this? Thanks. >>> >>> >>> > >
|
|
Ken, Thanks for your help. Actually my original code re this find eventually worked in this form. (Remembering that it works in two other forms just fine!)
I have been having what I call "Out of body Access experiences" with this form even though it is prettey straight forward (not complicated transactional) code. Some are not recreatable and at least one is. I am about to post it seperately. It is seemingly phantom code.
Anyway, thanks again. Elaine
"Ken Snell (MVP)" wrote:
[Quoted Text] > Sorry, typos in my codes: > > Private Sub SrchRec_AfterUpdate() > If Len(Me.Srch.Rec.Column(0) & "") > 0 Then > With Me.RecordsetClone > .FindFirst Me.SrchRec.ControlSource & "=" & Me.SrchRec.Column(0) > If .NoMatch = False Then Me.Bookmark = .Bookmark > End With > End If > End Sub > > > Private Sub SrchRec_AfterUpdate() > If Len(Me.SrchRec.Column(0) & "") > 0 Then > DoCmd.FindRecord Me.SrchRec.Column(0) > End If > End Sub > > > -- > > Ken Snell > <MS ACCESS MVP> > > > "Ken Snell (MVP)" <kthsneisllis9[ at ]ncoomcastt.renaetl> wrote in message > news:OfUFIjTyGHA.4232[ at ]TK2MSFTNGP04.phx.gbl... > >I recommend using the AfterUpdate event of the combobox, not the Click > >event, to run search code. > > > > Is CmpltNum the name of the form on which this combobox is located? Are > > you trying to search within the same form? > > > > Is the combobox bound to a field in the form's recordsource table or > > query? Is that the field in which you want to find the selected value? > > > > Assuming all answers are yes, here is the code that I recommend: > > > > Private Sub SrchRec_AfterUpdate() > > If Len(Me.Srch.Rec.Column(0) & "") > 0 Then > > With Me.RecordsetClone > > .FindFirst Me.SrchRec.ControlSource & "=" & Me.Srch.Rec.Column(0) > > If .NoMatch = False Then Me.Bookmark = .Bookmark > > End With > > End If > > End Sub > > > > The above assumes that the field to which the combo box is bound is a > > numeric field. If it's text or date type, then a slight change is needed > > in the code syntax -- but I'll not post that unless you indicate that the > > field is one of these. > > > > Otherwise, using your FindRecord code, this should work: > > > > Private Sub SrchRec_AfterUpdate() > > If Len(Me.Srch.Rec.Column(0) & "") > 0 Then > > DoCmd.FindRecord Me.Srch.Rec.Column(0) > > End If > > End Sub > > > > > > -- > > > > Ken Snell > > <MS ACCESS MVP> > > > > "Elaine" <Elaine[ at ]discussions.microsoft.com> wrote in message > > news:96EFBF2A-6467-4D92-B829-3E2E23447EBE[ at ]microsoft.com... > >> Ken, > >> It is one form (no sub forms). I have tried the record source being a > >> table > >> as well as a query. There is a combo box that selects records from the > >> table > >> in which I want to select the record. The user selects the record and in > >> the > >> on click of that field, the following code runs: > >> > >> Private Sub SrchRec_Click() > >> On Error GoTo Err_SrchRec_Clk > >> GlbCBIDSrch = Empty > >> GlbCBIDSrch = Me.SrchRec.Column(0) > >> Dim Fnd As Variant > >> Fnd = Me.SrchRec.Column(0) > >> > >> Forms![frmcbopen]![CmpltNum].SetFocus > >> DoCmd.FindRecord Fnd > >> > >> Forms![frmcbopen]![CmpltTyp].SetFocus > >> > >> Exit_SrchRec_Clk: > >> Exit Sub > >> Err_SrchRec_Clk: > >> ErrorMessage ("CBOpen Srch Record Click") > >> Resume Exit_SrchRec_Clk > >> End Sub > >> This exact code used in the same manner works on other forms in this same > >> mdb. There are 124 fields on the form and in the sql table which is more > >> than in the other forms/tables. Aside from that, I see no differences. > >> > >> I would prefer to us a query with a like statement looking at the primary > >> field being equal to the field on the form. In that way the user does > >> not > >> have a record appearing until they select something. However, at this > >> point, > >> anything is ok if it works! (Note a bit of frustration going on... > >> :) ) > >> > >> Thank you for your help, Elaine > >> > >> > >> "Ken Snell (MVP)" wrote: > >> > >>> You'll have to tell us a lot more details about the form, where/when > >>> you're > >>> using this, how you're using this, etc. This error message usually shows > >>> up > >>> when (1) some other event is blocking the moving to another record; (2) > >>> an > >>> error exists in the programming that is running at that time; (3) your > >>> setup > >>> is not proper for using this action; etc. > >>> > >>> -- > >>> > >>> Ken Snell > >>> <MS ACCESS MVP> > >>> > >>> > >>> > >>> "Elaine" <Elaine[ at ]discussions.microsoft.com> wrote in message > >>> news:11013B2B-36B5-43ED-8BF3-4404D726111C[ at ]microsoft.com... > >>> >I am using this in other forms in the same frontend mdb and it works > >>> >fine. > >>> > In one form, however, it does not. I have tried the form's record > >>> > source > >>> > as > >>> > both the a table and a query. > >>> > > >>> > Anyone found a reason or solution for this? Thanks. > >>> > >>> > >>> > > > > > > >
|
|
|