SetFocus On A Selected FieldName
Apr 24, 2005I have a form with numerous fields and would like to be able to move the focus to a selected field by typing the field name into a control box. How can I do this? TIA
View RepliesI have a form with numerous fields and would like to be able to move the focus to a selected field by typing the field name into a control box. How can I do this? TIA
View RepliesI have got a query which gives me the following output;
Nr ----------- area ------- area 2 ---------- holler
14-1096-------1------------1-----------------5.9
14-1097-------2------------2-----------------7.8
14-1100-------1------------1-----------------13.4
14-1101-------2------------2-----------------7.8
What i would like to do is to calculate the sum of holler when they are in the same area.So the sum of nr 14-1096 + 14-1100 and 14-1097 + 14-1101. Ive tried to do the following;I tried to do the following just to check it would even work;
Code:
test: (SELECT Sum([holler]) FROM querytoetsn2hr_gemiddelde_filter WHERE ((querytoetsn2hr_gemiddelde_filter.area)=("1")))
Which worked perfectly, it gave me 19.3..
Code:
test: (SELECT Sum([holler]) FROM querytoetsn2hr_gemiddelde_filter WHERE ((querytoetsn2hr_gemiddelde_filter.area)=(querytoetsn2hr_gemiddelde_filter.area2)))
That gave me the sum of all 4 the Nrs. Which makes sense, because you basically say that as long as area and area are the same calculate the sum of holler.if there is a way to say "sum of holler when area has the same value".
I ahve in error typed the above - however it compiles and compacts and repairs without throwing an error. Should this be spotted before I actually run the line of code??
Ta
I am trying to create a query that can be customised by a combobox.
I have a combobox that lists the fieldnames from table (rather than records)
I want to be able to run a query that updates the field selected from combobox with the vaule from another txtBox
What I want to be able to write in SQL is;
UPDATE Products
SET [Forms]![Master_Form]![Combobox] = [Forms]![Master_Form]![Qty]
WHERE (((Products.ProductName)=[Forms]![Master_Form]![ProductName]));
But of course this does not work.
Any help would be appreciated in SQL or VBA?
I have a form with 48 unbound text fields name txt1 to txt48.
These are to represent 24 hrs in half hours, to visually represent the hours capacity of my workshop. Now if I choose a date, which is say Monday, I check my settings, and see that the workshop has a capacity of 15 hrs on a monday. Now I would like to in a loop set the backcolour of the remaining fields to red.
Something like for I = 15 (workshop capacity) to 48
me."txt" & I.backcolour=1111
next I
I have a report named rpt100 with two subreports srpt100a and srpt100b. The subreports are based on query qry100a and qry100b. Both queries are based on tbl100. I removed a field named 'Comment' from tbl100, as it wasn't useful; Also removed the fieldname from both qry100a and qry100b. When opening rpt100 a parameter dialog opens asking for data on the deleted fieldname 'Comment'. The field 'Comment' was never used in the report or subreports.
Inspection of the subreport fieldlist shows field 'Comment' still present.
How, other than remaking the rpt100 and both srpt100a and srpt100b, do I remove the field 'Comment'?
Gunner...:confused:
As example, I have a table with an Item number, introduction year and a number of historical and future Sales periods set per year, these sales columns are listed Y1990, Y1991, Y1992....... Y2015.
Based on each items introduction year, I want to list the first 5 years of sales.
I wanted to create a dimensional fieldname eg: FirstYear: "Y"&[introduction year] to get the value of that respective year. (I currently just get a text saying "Y1995", and not the content )
Any help is appreciated!:)
(Note: I can't transpose the data in the tables for other reason)
Access 2010 report. I am trying to use DCount but have a string for the fieldname and cannot figure out the correct syntax. This is what I have tried:
txtMiscYes1 = DCount("[" & str1 & "]", "tblTemp", "[" & str1 & "]" = '1')
I want to count any answer that has a 1 and skip a 2 or 3 answer.
I want to use a variable as FieldName in the DLookup function.
Normal DLookup:
Code:
DLookup("FieldName" , "TableName" , "Criteria= 'string'")
I want to use:
Code:
DLookup(variable, "TableName", "Criteria= 'string'")
Where variable is an integer, which represents the column number in the table.
Is this possible?
I have a database where I would like to change a fieldname to something different.
I know I can use edit replace in the code and that works ok, but is there a way to change the fieldname in the code, the Table, the queries, and sql all in 1 foul swoop or do I have to do them all seperately by hand.
Hello all :)
I've read some really funny stuff while searching for an answer to this. You're a bunch of really witty types :)
So I'm sure someone can help me - why would this entered data not make it into the table?
I have a form that has a subform. After the subform I have a button to continue. If this is clicked I change the visible property for another field to true. This field appears to work fine, but the data doesn't make it to the underlying table, in fact it sometimes seems to be included in the next record.
Any ideas?
Thanks
A.
Hi,
Self learning trying to modify a query fieldname and criteria thru code.
Have a small form with a button making a copy of a query/s (eventually making about 50 copies).
Once these have been made, would like to open the query up, which I can do, then modify both
the fieldname and the field criteria to suit my needs from parameters set in the form.
How do I do this if it can be done ?
Thanks in advance
Ian T
How can I set the focus to the first control in a form, without referencing the control name?
Ex. Normally I do:
Me.ControlName.SetFcous
Now I have a code which adds a new record, which is used on several forms, therefore the control name is not always the same, so I would like the focus to move to the first field on the tab order. Any ideas please?
I am just learning VB, much less Access, even more so how to just understand all the code. My conundrum: In my form, I have 4 sets of tabs (not pages - each tab contains +/- 8 pages). Each tab is controlled visibly by 1 of 4 text boxes within the form, not positioned within the tabs. When each respective control is clicked, it is bolded (i.e. fontbold = true) and its repective tab set becomes visible (i.e. true), "hiding" the other 3 tab sets (i.e. visible = false). This is dependent on changing setfocus to the control (according to my error messages which say I cannot move the setfocus to the control or I can't hide a control that has the focus). After I try to setfocus to Tab2 and click the control for Tab2, it says the same thing, that I can't hide a control that has the focus. I've tried setting focus to the tabs, to the labels that control the tabs, to labels within the tabs, and to text within the tabs - all to no avail. If anyone has a suggestion, I would be most appreciative. Cheers.
View 3 Replies View RelatedIm running a query and normally there is only a field-name in heading. I have
multiple tables with equal field names. Now I want to get table names in
heading too (Tablename.Fieldname) so I can make difference between fields on each tables when previewing query. Is this possible in access? I don't want to change all field-names manually, I know it's possible and done easily, but there are almost hundred fieldnames...
Im finding a solution. Help me please. Thanks :eek:
- Roger
--
Have a nice day.
Hey guys, I am trying to input data into a form, the form consist of mulitiple tables. Once I set it up I get a "#Name?" error in the text box, and when I try to input data into the text box, at the bottom of the form it keeps saying "control can't be edited; it's bound to unknown field 'FieldName'."
Can anybody help me with this problem?
Thanks
If a user enters too many characters into a field I want to display a message and then keep the user in that text box until less characters are entered.This is the codePrivate Sub txtTitle_LostFocus() txtTitle.Value = LTrim(txtTitle.Value) If Len(txtTitle.Value) > 50 Then MsgBox "Title is too long. Can not be more than 50 characters", vbOKOnly, "Title Too Long" txtTitle.SetFocus End IfEnd SubThe message appears but focus moves to the next text box almost as if the setfocus command has been ignored.Anyone got any ideas as to why??Thanks
View 6 Replies View RelatedMy form is in tabular form so it is just a running list. How do I SetFocus to a new record when the form is opened?
View 4 Replies View RelatedI have a form with a button that when clicked triggers "find" in a field that is located on the form...
[code]Private Sub Command23_Click()
DoCmd.GoToControl "last name"
DoCmd.RunCommand acCmdFind
End Sub [code]
When the record is found and the user presses "esc" to close the find box I would like to set the focus in a field located in the subform...
[code] Private Sub Form_Current()
Me.LT2DataEntrySubform1.Form!QRt.SetFocus
End Sub [code]
Problem is after the user presses "Esc" both the field on the form that is used to seach on and the field in the subform that I set the focus on have the focus. Yes...both fields have focus and unless the user clicks on some other field no dataentry can be done.
Any suggestions would be appreciated.
Thanks
Hello,
I have litle problem regarding SetFocus.I have 2 Forms - form1 and form 2.On form 1 I have txtSomething and when I open form2 I can not SetFocus on txtSomething.I have tried with
Forms!Form1!txtSomething.SetFocus
but something wrong,can someone help,
thanks
I'm having an issue with part of my code. I have a logout function which closes one form and then reopens the login form. It does this fine, but I can't type in any of the text boxes on the login form unless I close it out and reopen it manually. Here's the code:
vb Code: Original - vb Code Private Sub cmdLogout_Click()On Error GoTo Err_cmdLogout_ClickDoCmd.OpenForm "userlogin", acNormal, , , acFormReadOnly, acWindowNormalForms!userlogin!txtuserid.SetFocusDoCmd.Close acForm, "Control Panel", acSaveNoForms!userlogin!txtuserid.SetFocusExit_cmdLogout_Click:Exit SubErr_cmdLogout_Click: MsgBox Err.Description Resume Exit_cmdLogout_ClickEnd Sub Private Sub cmdLogout_Click()On Error GoTo Err_cmdLogout_ClickDoCmd.OpenForm "userlogin", acNormal, , , acFormReadOnly, acWindowNormalForms!userlogin!txtuserid.SetFocusDoCmd.Close acForm, "Control Panel", acSaveNoForms!userlogin!txtuserid.SetFocusExit_cmdLogout_Click:Exit SubErr_cmdLogout_Click: MsgBox Err.Description Resume Exit_cmdLogout_ClickEnd Sub
I've tried setting focus as shown above, but still no luck. Any ideas?
Thanks,
JMH
Hi,
For some reason when I set the focus to a text box in the subform it clears the textboxes there.
First I set the values of 2 of the textboxes in the subform programatically. Then I tab to the last control in the main form. This is the code I have in the lost focus event of that control:
Forms!frmDrawingsRegister!frmDrawingRevisions.SetF ocus
Forms!frmDrawingsRegister!frmDrawingRevisions!txtL atestIssueDate.SetFocus
frmDrawingsRegister = main form
frmDrawingRevisions = subform
I have set the Cycle property of the subform to Current Record.
Why would this be happening?
I have a main form with a subform which in-turn also has a subform (in datasheet mode). When the user clicks a button on the main form I want to disable all of the controls on the subforms. This works fine until the user clicks the button while the focus is on one of the text fields in one of the subforms. It rightly complains that the control can't be disbled while it is in focus. To circumvent this problem I've tried setting the focus to another field before disabling the control. However this doesn't seem to work. It seems to ignore the setfocus and still flags the original error. Is it not possible to set the focus of a subform from the main form?
Example:
[subfrm1].Form![Field2].SetFocus
[subfrm1].Form![Field1].Enabled = False
This fails if the focus was in Field1 at the time of executing the code.
Any ideas?
Hello,
I have a continuous form. On that form, I have a link (label) that a user can click to bring up a new form containing more info on the current record. The problem is that when the form opens, the first record is selected. If the user scrolls down to another record, and clicks the link, the form opens with info on the first record.
It seems that I need to set the record to the record that the link was clicked from, but I'm not sure how. Any help?
Thanks,
Eric
I'm using the following code (from GHudson) to check for required fields being filled in but it stops at a particular combo box and gives the error message Runtime error 2110 "can't move the focus to the control" although it works on previous combos which are set up in the same way.
Private Sub Close_Click()
'Key "Required" in the Tag property of the form object.
Dim ctl As Control
For Each ctl In Me
If ctl.tag = "Required" Then
If IsNull(ctl) Or ctl = "" Then
MsgBox "You must complete all required fields to continue. Your cursor wll now be set to the missed field", vbCritical, "Required Field"
ctl.SetFocus
Exit Sub
End If
End If
Next
Set ctl = Nothing
DoCmd.RunCommand acCmdClose
'If MsgBox("Have you selected the record type and filled in the other yellow fields? These are mandatory. If you haven't - click on 'No' to return to form", vbQuestion + vbYesNo, "Open Form?") = vbYes Then
'DoCmd.SetWarnings False
'DoCmd.RunCommand acCmdClose
'DoCmd.SetWarnings True
'End If
End Sub
Sorry if this has come up before, I have been chasing dozens of threads that are so close, I've still not got it!:o
I have a form that is used in edit mode and add mode. When used in edit mode it has a combo box in the header that does the usual bookmark search in the after update event, and on open focus is set to this field in the open form event.
When in add mode i don't want this set focus to happen so I'm not sure what the test statement should be.:confused:
Would appreciate a pointer or two.
lightray