I need to know how to get the record count from a query. I know this is probably simple, but I'm at a loss right now.
I have a query that is the source for a report, but I want to know (before the report runs) if there are no records so I can not even bring up the report on the screen (in...
GOOD news. After reviewing the code, I had a typo... so the first suggested fix DID fix it. Now the code works. So I had to first set the focus on the FORM, and then set the focus on the FIELD. That was the fix. Thanks for both of you. Case solved! Yea!!
Yes, you're right. It's NOT the field name, it a variable that contains what I'm seeking, not where I'm seeking.
I know it's right 'cuz my debug messages confirm what I'm loking for.
Silly me... sorry for the confusion. So any ideas?
Well, that avoided the eror on the FindRecord, but it didn't move to the desired record within the subform.
Progress :-) ... but not success. :-( Any other ideas?
I tried to get this figured out a few months ago but it never worked.
I am specifying the record set within the main form, and after the correct recordset is brought in for the subform, I want to then change the current record within the subform, not just stay at the first record found in the...
Okay, the latest chapter in this soap opera.
I tried the following code:
Forms!frmCustomerEntry!theform.SetFocus
I received the error 2465 ("MS Access can't find the field 'theform' referred to in your expression."). :-(
In case I needed the .Form property, I then tried...
Now this is getting strange. I just read that Screen.ActiveForm will refer to the main form, even if the subform has the actual focus.
So I guess the correct reference would be (I'm hoping) Screen.ActiveControl.Parent, and to get the name of the active form (even if it's a subform), it would...
Per your last post...
PrevFormName = Screen.PrevControl.Parent.Name
Then my previous post...
PrevControl = Screen.PreviousControl
PrevForm = Screen.PreviousControl.Parent
ChgForm = PrevForm.Name <> "subFormName"
Between the lines in my post, I think I already got your suggestion already in...
I'm guessing that I can merely do something like:
PrevControl = Screen.PreviousControl
PrevForm = Screen.PrevControl.Parent
' Does above reference the current form or parent of?
ChgForm = PrevForm.Name <> "subFormName"
If ChgForm Then Me!subFormName.SetFocus
Me.TextFieldName.SetFocus...
As to your follow-up response:
That explains a few areas that were a bit cloudy before as they apply to VBA usage.
Okay, I understand your flicker point completely. Let me just clarify my usage. The code in question only executes once when the user changes customers by specifying an item...
A follow question:
If I set the focus upon the field within the subform, does that implicitly set the focus upon the form? Or must I first set the focus on the form and then set the focus upon the field itself?
I thought I had set the focus upon the field, or is the problem that since it...
Actually, the only reason I was trying to set the focus on one of the fields was solely to find the desired record within the subform. The mere fact that you felt that it wasn't the reason I was doing it does catch my attention. Is there another way I could achieve the same results (changing...
Okay, asusming that fixes the problem (I won't know until I get back to work on Monday), why is this even needed?
The implciation being that the current active control isn't the form in which the routine is executing. I never even considered that.
Since the previous lines (e.g., the MsgBox...
If we're trying to do tighter code :-), why not just do:
str = str.replace(/\s$/,"");
Yeah, it is one character shorter. LOL.
Though I kinda prefer
if (str.charAt(str.length-1)=" ") str=str.slice(0,-2);
... since it would seem to execute faster -- only a simple test on the last position...
You don't need to modify all the places you use the referrer. Just put some code at the top of the entry routine.
In that code, grab the referrer and put it into a named variable -- with that error-trapping code on. Inside the error-trapping code (which would only execute when you get the...
Okay, the most recent update on this problem.
I'm able to successfully call the routine within the subform. Under some circumstances, the .SetFocus does appear to work -- well, I don't get an error, and I know this because the following line (a MsgBox does execute and I get the expected...
Maybe I'm missing something, but don't those two "Microsoft" references conflict with each other -- one says 'read/write' and the other says 'read only' -- or is something missing from my comprehension?
The other thing I noticed was that the first MS reference says that the index returns '0'...
My first reaction would be to say maybe you're right....
But the SetFocus is called within the called routine and no error occurs -- I know this because the next line is a MsgBox and it executes (i.e., I get the msg in the screen). It's not until the NEXT line (the FindRecord) that the On...
In the main form:
Call [Listings].Form.FindABItem(itemNumber)
In the sub-form:
Public Sub FindABItem(ABItem As Integer)
On Error GoTo Err_FindABItem
.
.
.
MsgBox "Starting at item #" & Me.Item_Number & " and searching for #" & ABItem
Me.Item_Number.SetFocus
MsgBox "Focus has been...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.