I know how to do the exit values but I am not sure how to do that first part. All of the names of the tables, queries, forms are the same
what 'first part' you mean adding the unbound combo box? just add a combo box and make the data source the same as I did in my example or just copy the combo box from my example to your form, then you just have to attach the on exit code to it
I am not sure what you meant by copy the combo boc from your example, but i simply copy and pasted it into my form and added the exit code but it is not working. it lists all of the ContractIDs in the search but when it does not refresh it when I click outside of that search box to reflect the changed ContractID
then you're not changing the ON EXIT property of the combo box, remember when you copy the combo box from my example to your form it does NOT preserve the name of the combo box so you will have to modify the ON EXIT Property manually
I copied all of the code from the ON EXIT property of your example to mine. both are called searchfield.
This is what is in yours and is working:
Private Sub searchfield_Exit(Cancel As Integer)
Me.Requery
DoCmd.GoToControl ("COUNTERPARTY")
End Sub
This is what is in mine and is not working:
Private Sub searchfield_Exit(Cancel As Integer)
Me.Requery
DoCmd.GoToControl ("COUNTERPARTY")
End Sub
go to the design view of the form
go to your searchfield text box go to the ON CLICK event. does it say [Event Procedure] or is it blank? If it's blank you haven't reestablished the event you want to run so click the three dots to the right your code should already be there, then just close the vb window and it should run as normal. You can't just copy code for events and have it work. You still have to go to the event procedure building portion, even if it automatically finds your code you still have to do it.
when i first clicked it, it was blank. and then now when i open it my code is there but it still does not work. i am not sure what you mean by the three dots to the right of my code.go to the design view of the form
go to your searchfield text box go to the ON CLICK event. does it say [Event Procedure] or is it blank? If it's blank you haven't reestablished the event you want to run so click the three dots to the right your code should already be there, then just close the vb window and it should run as normal. You can't just copy code for events and have it work. You still have to go to the event procedure building portion, even if it automatically finds your code you still have to do it.
I don't know what to tell you then, you're doing something differently between the two databases what I would suggest is importing the form that works into the database that doesn't and seeing if the imported form works. If it does there's something different in your database setup. If it doesn't work something else is going on. The three dots appear when you click on the ON CLICK event at the far right hand side of the properties window, that's what you click when you want to build an event.
i dont see any dots, perhaps it is becuase i am using a different version of access, to build i right click and chose buildI don't know what to tell you then, you're doing something differently between the two databases what I would suggest is importing the form that works into the database that doesn't and seeing if the imported form works. If it does there's something different in your database setup. If it doesn't work something else is going on. The three dots appear when you click on the ON CLICK event at the far right hand side of the properties window, that's what you click when you want to build an event.
importing the form does not work. when trying to run it i get an error for Enter Parameter Value: Form!Contracts Form!searchfield!
When I right click and choose to build an event it defaults to AfterUpdate. So I'll say it once again, scroll down to your ON CLICK event property of your SEARCHFIELD text box click on that row. Does it say [Event Procedure], does it say nothing, does it say [Event Procedure] in any other event? if it does delete it, click on the ON CLICK event row, three dots will appear on a button to the far right, click THAT button then choose the code option then paste in the code.
Or as I said import the form that works into your database and see what happens.
So your forms are not exactly the same. You've changed the name of either your form or your search field or both at the very least. when you get the parameter value error it's basically telling you it doesn't know how to evaluate
Form!Contracts Form!searchfield
this
if this is exactly how it appears in your code it isn't going to work, access does not like spaces in object names (table names, field names, form names, report names, etc, etc, etc.)
so try forms![contracts form]![searchfield] but you *must* be sure these object names (text box names) are on your form and that your form is actually called 'contracts form' or you will continue getting the parameter value error.
when I go to CLICK in the event property after right clicking and hitting build it shows all of this:
Private Sub searchfield_BeforeUpdate(Cancel As Integer)
End Sub
Private Sub searchfield_Click()
End Sub
Private Sub searchfield_Exit(Cancel As Integer)
DoCmd.GoToControl ("COUNTERPARTY")
Me.Requery
DoCmd.GoToControl ("COUNTERPARTY")
End Sub
If I dont click on build and click zoom it says [Event Procedure] and nothing else
all of the names are the same except when i imported in the form it named it Contracts Form1So your forms are not exactly the same. You've changed the name of either your form or your search field or both at the very least. when you get the parameter value error it's basically telling you it doesn't know how to evaluate
Form!Contracts Form!searchfield
this
if this is exactly how it appears in your code it isn't going to work, access does not like spaces in object names (table names, field names, form names, report names, etc, etc, etc.)
so try forms![contracts form]![searchfield] but you *must* be sure these object names (text box names) are on your form and that your form is actually called 'contracts form' or you will continue getting the parameter value error.
I meant to capitalize it in the earlier post about the error. i tried putting what you said into the parameter value and even with contracts Form1 but it does not bring in any info
this is three different events.Code:Private Sub searchfield_BeforeUpdate(Cancel As Integer) End Sub Private Sub searchfield_Click() End Sub Private Sub searchfield_Exit(Cancel As Integer) DoCmd.GoToControl ("COUNTERPARTY") Me.Requery DoCmd.GoToControl ("COUNTERPARTY") End Sub
one is the BEFORE UPDATE event of your searchfield (which is doing nothing)
one is the ON CLICK event of your searchfield (which is doing nothing)
and one is the ON EXIT event of your searchfield in which you're calling your gotocontrol twice.
so firstly, and for the last time, please, please, please just click on the ON EXIT event of the SEARCHFIELD text box. Click ONCE on the row that says ON CLICK. At the far right hand side of that row a small button will appear that has three dots on it (...). Click that button it should take you to the section of code that says:
if it does, remove remove the first DOCMD.GOTCONTROL("COUNTERPARTY")Code:Private Sub searchfield_Exit(Cancel As Integer) DoCmd.GoToControl ("COUNTERPARTY") Me.Requery DoCmd.GoToControl ("COUNTERPARTY") End Sub
if it does NOT then you have not named your searchfield correctly and you have to rename the unbound textbox to SEARCHFIELD, then go back through this same process to attach the code to your ON CLICK event.
Secondly. If you are getting a parameter value prompt you have NOT named all of your objects the same, either your form name or your unbound text box SEARCHFIELD is no longer named SEARCHFIELD (as mentioned above) and you need to fix those two items.