Validation Before Focus Enters Subform
Aug 25, 2004
When I click on my subform after entering some data in the primary form, I get this error message:
"The Microsoft Jet database engine can't find a record in the table <name> with key matching field(s) <name>. (Error 3101)"
This is because I have not filled in a ItemCode, a combobox, on the parent form and ItemCode is part of a one-to-many relationship that involves automatic filling in of other fields such as ItemDesc, UnitPrice, etc. How do I code the validation that handles such an error?
Thanks in advance,
Swee
View Replies
ADVERTISEMENT
Jan 2, 2007
I have 4 nested forms:
DataEntryMaster
DataEntryMainSub (subform on DataEntryMaster)
DataEntrySub2 (subform on DataEntryMainSub)
DataEntrySub3(subform on DataEntrySub2)
In the AfterUpdate even of DataEntrySub2, I have code that checks to make sure the field on DataEntrySub3 (it has only one field) has been filled in. If not, I want to set the focus to DataEntrySub3.
The code in the DataEntrySub2 afterupdate event:
if isnull(me!dataentrysub3.productbarcode then
msgbox "You must enter a product barcode!"
forms!dataentrymaster!dataentrymainsubform!setfocu s
forms!dataentrymaster!dataentrymainsubform!dataent rysub2.setfocus
forms!dataentrymaster!dataentrymainsubform!dataent rysub2!dataentrysub3.setfocus
end if
I've used this most-wordy syntax because I couldn't get the shorter syntax (eg, me.dataentrysub3.setfocus) to work at all. However, this STILL doesn't work.
What's really puzzling is that if I run those exact same 3 setfocus statements from the immediate pane, they work fine. But in the afterupdate event, my focus always ends up on a control in dataentrysub2.
Any ideas???
View 1 Replies
View Related
Mar 9, 2005
Well, the title says it all really. After I click into the subform and type something in a text box, the focus will not return to the parent form, via mouse or tab. I can't even switch the form back into design view, it appears to be totally locked. Has anyone run into this before?
View 4 Replies
View Related
Sep 28, 2006
i won't go into details except i am doing databases for cemeteries - very complicated
example
i have come across two people who have the same name, date of death, buried in the same grave on the same day but are not related and must have seperate records!!
my main table has 6 primary keys. [even then i have 2 duplicates who are not related]
anyway one of the problems is this
i have a main form with 2 subforms. the main form is unbounded. i need to copy information from 1 of 4 queries run by the main form [QBF] to one of the subforms. i don't know which query untill i view the data.
when i know which one, i press a command button which copies the information to one of the subforms. when i repeat the actions above instead on the new query data going into a new record on the subform it overwrites the existing data instead of pasting it into a new record.
i have tried setfocus command - this works only if i click on the subform and activate it [this defeats the object of the command as i might just as well click in a new record box on the subform].
in essence i do not need to activate this subform at all. i just need to check if a record exists and if it does goto a new record [again this works only if i physically click on the form]
any ideas how i can force the cursor to goto a new record without physically clicking on the subform??
thanks
View 6 Replies
View Related
Mar 20, 2014
If i open a form with a sub form on can i open it so that the focus go directly to a control on a sub form.I have tried to do it with a macro on the on open event to go to control but it comes up that the control don't exists on the sub form.i am using access 2010.
View 6 Replies
View Related
Mar 7, 2014
I have a form with a subform on it. The subform has subforms. I need to set the focus on a control on one of the subforms. Here is what I am using.
START OF CODE
Forms!frmMain!frmMainSub.Form.frmContactLog.SetFoc us
Forms!frmMain!frmMainSub.Form.frmContactLog.Contac tMethod.SetFocus
END OF CODE
I use Code 1 to get to the third level. Code 1 works.
Code 1
Forms!frmMain!frmMainSub.Form.frmContactLog.SetFoc us
When I add the second line, Code 2, it doesn't work. I get the message "Run-time error 438: Object doesn't support this property or method."
Code 2
Forms!frmMain!frmMainSub.Form.frmContactLog.Contac tMethod.SetFocus
View 2 Replies
View Related
Jan 21, 2015
I have a single main form with a datasheet subform. When I scroll through the records shon in the main form, each has a different set of child records shown in the subform.
I want the focus to be on the last record of the subform each time.
On the main form, I have a button and this code
Code:
Private Sub cmdLast_Click()
Me.frmRevisionsSub.Requery
Me.frmRevisionsSub.SetFocus
Me.frmRevisionsSub.Form.txtRevTag.SetFocus
DoCmd.GoToRecord , , acLast
End Sub
which works perfectly, when I click the button.
If I call this code from main form's OnCurrent, focus remains on the first line of the subform instead of going to the the last. I have an inkling that it has to do with when the requery of the subform takes place, when I scroll through the records on the main form.
View 1 Replies
View Related
Jan 2, 2014
I have a form with a subform which is sized to show several records at the same time. If Record A has the focus, and I click anywhere in Record B, then Record B gets the focus, as expected. ... Except if I click on an Image field in Record B, when the focus stays on Record A.
How I can force it to set the focus to the other record ? I don't think this can be done with Events handlers, as they need to have the focus set first.
View 5 Replies
View Related
Apr 22, 2015
Is it possible for an image control to change to a different picture on a form when focus changes to a different record on a subform? I am developing a simple database to record my ever growing collection of TV shows. The form that I use to view my TV show records has an image control on it, I previously had a single image for the entire series (box art for first season). I now want that image control to change to a different picture when the focus changes to a different record on the subform. i.e. when the focus changes from the first season on the subform to the second season; the picture on the main form changes with it.
View 7 Replies
View Related
Dec 17, 2014
I have a form, with a subform,
When a user selects a record from the subform i use this to view the record in the main form
Private Sub Txt_Support_Name_Click()
DoCmd.ApplyFilter , "ID =" & Me.ID
End Sub
However when i select the record from the subform, it populates the form as required, however then the top record of the subform is highlighted.
Any way to either - highlight nothing, or highlight the selected row?
View 4 Replies
View Related
Jun 29, 2014
I have a form that I created that has a tab control. When the form loads, it automatically sets the focus to a field in the subform. This wouldn't be a problem, except when it does it hides the tabs at the top of the form so I have to go and scroll back up every time I click a tab so that I can see the tabs. Is there a way to adjust this? I have tried hiding a field and setting the focus to it and that didn't work. I also tried setting the focus to the actual tab, but that also did not work.
View 8 Replies
View Related
Nov 19, 2014
I am trying to highligh a subform textbox a yellow color on focus. However it is highlighting every textbox in that field as it is a continuous form therefore they are all named ThisCount.
Is there a way to highlight just the specific textbox that I am in. I have tried.
Code:
Me.ThisCount.BorderColor =RGB(255, 215, 0) 'gold
Me.ThisCount.BorderWidth =3
and tried
Code:
Dim ctlCurrentControl As Control
Dim strControlName As String
Set ctlCurrentControl = Screen.ActiveControl
strControlName = ctlCurrentControl.Name
Set ctlCurrentControl = Screen.ActiveControl
ctlCurrentControl.BorderColor = RGB(255, 215, 0) 'gold
ctlCurrentControl.BorderWidth = 3
View 8 Replies
View Related
Apr 27, 2007
I apologize if this has already been covered, but I could not find an answer.
I have a form that assigns a quote number (autonumber) and for somereason everytime you enter a new record it enters two. So for every data record there is one empty record.
i.e.
2473 - blank
2474 - has data
2475 - blank
2476 - has data
Thank you for your help.:confused:
View 3 Replies
View Related
Nov 29, 2007
I am trying to run a pass-through query in access with a variable that a user enters in a form. I can't seem to get this to work. Can somebody please help? The variable should be where the 121212 is in the code.
Code
1:FROM doc..eco_summary es
2:INNER JOIN
3:((((mart..DM_Map dmm LEFT JOIN mart..DM_PI dpi ON dmm.Acct_ID = dpi.Acct_ID)
4:INNER JOIN mart..DM_Note dmn ON dmm.Acct_ID = dmn.Acct_ID)
5:INNER JOIN mart..DM_ACCT dma ON dmn.Acct_ID = dma.Acct_ID)
6:LEFT JOIN mart..DM_RE dmr ON dmn.Acct_ID = dmr.Acct_ID) ON es.L_loannum = dmm.Acct_ID
7:INNER JOIN weis..eco_loan_origination elo ON es.L_num = elo.num
8:where es.L_num = 121212
View 1 Replies
View Related
Jul 5, 2005
I'm sure this is really simple... apologies, but a search hasn't thrown up any clues.
I have a table with Invoice Value, and Commission Value in it. On the associated form I enter the Invoice Value, and also the Commisison value [which 99% of the time is set at 20%.
I am trying to make a button which, when pressed, enters the calculated commission in the form field (and underlying table) - I realise this could be in the 'On Click' property on the form, but in VBA I am after something like.
Private Sub btnCommCalc_Click()
tblSales.Commission = tblSales.Invoice * 0.2
End Sub
Could someone help me with the syntax? (I can then move on to using a variable, rather than hard-wiring the 20% ;-)
Many thanks
View 8 Replies
View Related
Nov 4, 2014
I have a form that incorporates 2 subforms. I have all but 1 thing working as intended. I have setup a button to submit the entries (and handle a few other control functions) but I need to validate a single control within the first of the 2 subforms. This should be simple but it seems I am missing something. I just need to check for null or blank and if true open a message box to explain that it is a required field and to then exit the sub without any further execution. My problem is that no matter how I type the code I cannot get it to recognize the control (which is a combo box). Even identifying the from the control is on does not seem to work.
View 1 Replies
View Related
Aug 14, 2013
I'm very new to access so I'm not sure about the correct way to go about this. I have a table with a 'category' column, a form which hides the category column, and a combobox to filter the category, let's say R, C, and F.
What I want accomplish is to have the value of the comobox applied to the hidden 'category' column when a user enters a new record into the form.
Is there I way I can get an instance to the record as it's being entered and modify the data using VB? Or would I have to write a sort of pop() function and have it run afterInsert and then modify it that way? Can I even alter the table using VB like this?
View 4 Replies
View Related
Aug 19, 2015
I am currently stuck on set focus property. I have a main from with nested subform. I am trying to move the focus from last field of the subform to another field on the main form.
Customers(mfrm)....>Addresses(sfrm)...>Orders(sfrm Add)......>OrdDetails(sfrmOrders)
Now I have a field name [Securedesign] in frmOrderdetails and I want the tab order to navigate to field [CustomerID] in frmAddresses which is a subform to frmCustomers.
View 2 Replies
View Related
May 6, 2005
I have a mainform (f1) and a subform (f2). The subform normally is not visible ([Fomrs]![f1]![f2].visible = Fasle). When I click on a command button on the main form, the subform wiill show up on the main form ([Fomrs]![f1]![f2].visible = True). There is another command button on the subform. When I click on the button, it opens up a third form (f3). The relationship between f1 and f2 is master-child, and the relationship between f2 and f3 is also master-child.
After I open the third form, I want to close (hide) the subform (f2), but I got an error saying that I can not "hide an object that is in focus".
Do you know any trick to do that? Thanks a lot.
Zoo
View 1 Replies
View Related
Dec 30, 2013
We are working on an Access (2007) database that is on a SharePoint Site (2007).
Currently the form is operational, but there is one last thing that would be nice to have.
The table is "Updated Headcount" which contains "EMP_ID" which are unique numbers stored as text.
In the event a new employee is entered in the system by another user on this site we would like to prevent any duplicate "EMPID"s from being entered and saved on the SharePoint, we would also like to alert the user and prevent the data from being saved.
All data is currently bound, so once the user makes a change it is made, no submit button is required.
We are running into some difficulties in doing a dlookup from the value entered and comparing to a column in the table.
TABLE - UPDATED HEADCOUNT
COLUMN in UPDATED HEADCOUNT - EMPID
FORM CELL user will input an EMPID - newEMPID
FORM CELL used for a dlookup to compare what user has entered to what is already in the table - duplicateEMPID
So below is what we are trying to do, we are sure there are a few commands missing....
=IIF(newEMPID=dlookup([UPDATED HEADCOUNT]![EMPID]), newEMPID, "Error, EMPID already exists")
View 11 Replies
View Related
Mar 24, 2005
I have several forms and subforms that display data, but are not used for data entry. The first textbox on every form gets the focus on open. I'm sure I've seen some way to open the form with no focus on any control!
Can someone help me remember?
Thanks,
Sup
View 3 Replies
View Related
Apr 15, 2005
thanks for helping.
how do i get a record to get focus when a form opens or a button is clicked on?
thanks again
View 2 Replies
View Related
Jan 9, 2006
I am having trouble getting the cursor to change focus after updating a field in my tab control subforms. I have a main form with a tab control and 4 related subforms for each record in the main form.
I have a calendar that pops up with the On Click of my Date field. When the date is selected, it enters it into the field and the calendar closes. For some reason though the user cannot simply go to the next record with the mouse and has to tab to or select another field in the same record first and then click on the Date field in the next record.
I have tried SetFocus to "Hours" (the next field after "Date")and "NextRecord" on every Event I can think of but it does nothing, it just stays on the changed field and the only way to get out of it is to go to another field. I've tried saving, requery, etc. I've also tried the options shown in the forum with no luck and using different events associated with the Calendar form - On Close, Lost Focus, etc.
Any suggestions? Thanks
View 6 Replies
View Related
Nov 9, 2006
I have a form that has 9 tab pages. I have an amend button in the form footer that will do a different thing depending on which tab has the focus. How can I find out which tab has got the focus when I click the Amend button?
View 2 Replies
View Related
Nov 30, 2006
Hi
I have a problem with setting focus to a text box. There is a listview on the form. Double clicking on a row will search the database for that record using SNo field and then display the contents on the respective control. When I click on a row the first time, it works. Clicking on the second row immediately gives the error "error 2110 - Access cannot set focus to the control txtReference.
Here is the code.......
Private Sub lvwOrders_DblClick()
ClearAll
Set rs = New ADODB.Recordset
rs.Open "SELECT * FROM tblOrderEntry where sno=" & ListView.SelectedItem, con, adOpenKeyset, adLockPessimistic
lblFooter.Caption = "Edit Record"
subRetrieve
End Sub
Private Sub subRetrieve()
Form_OrderEntry.SetFocus
With rs
For i = 0 To lstCostCenter.ListCount - 1
If lstCostCenter.ItemData(i) = !CostCenter Then
lstCostCenter.Selected(i) = True
Exit For
End If
Next i
txtReference.SetFocus
txtReference.Text = !ReferenceNo
txtOrderNumber.SetFocus
txtOrderNumber.Text = !OrderNo
For i = 0 To lstCostCenter.ListCount - 1
If lstCostCenter.ItemData(i) = !CostCenter Then
lstCostCenter.Selected(i) = True
Exit For
End If
Next i
For i = 0 To lstDescription.ListCount - 1
If lstDescription.ItemData(i) = !Description Then
lstDescription.Selected(i) = True
Exit For
End If
Next i
For i = 0 To lstOrderStatus.ListCount - 1
If lstOrderStatus.ItemData(i) = !OrderStatus Then
lstOrderStatus.Selected(i) = True
Exit For
End If
Next i
For i = 0 To lstSalesRep.ListCount - 1
If lstSalesRep.ItemData(i) = !SalesRep Then
lstSalesRep.Selected(i) = True
Exit For
End If
Next i
For i = 0 To lstPaymentMethod.ListCount - 1
If lstPaymentMethod.ItemData(i) = !PaymentMethod Then
lstPaymentMethod.Selected(i) = True
Exit For
End If
Next i
For i = 0 To lstCallType.ListCount - 1
If lstCallType.ItemData(i) = !TypeofCall Then
lstCallType.Selected(i) = True
Exit For
End If
Next i
For i = 0 To lstStatus.ListCount - 1
If lstStatus.ItemData(i) = !Status Then
lstStatus.Selected(i) = True
Exit For
End If
Next i
If !Status = "Pending" Then
txtReasons.Visible = True
lstAssign_Reasons.Visible = False
txtReasons.SetFocus
txtReasons.Text = !Reason
ElseIf !Status = "Assign" Then
lstAssign_Reasons.Visible = True
cmdSave.SetFocus
txtReasons.Visible = False
For i = 0 To lstAssign_Reasons.ListCount - 1
If lstAssign_Reasons.ItemData(i) = !Reason Then
lstAssign_Reasons.Selected(i) = True
Exit For
End If
Next i
End If
End With
End Sub
What can be going wrong ?
View 3 Replies
View Related
Apr 11, 2008
Hi everyone,
how would i go about setting focus on a tab control? i have a tab control on a form with 6 tab pages. i am on page 4 ( bank ) and i have a button to add a bank account. this opens up the add form and i add the account. i then requery the form and the tab goes back to page 1. how do i set the focus back to the previous opened tab?
many thanks,
Nigel
View 2 Replies
View Related