Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo box selection to change query

Status
Not open for further replies.

Allilue

Technical User
Joined
Sep 14, 2000
Messages
189
Location
GB
hello! Can someone point me into the right direction here?

I have a form that is linked to a query. I'm trying to create dropdown that allows the user to select a date. Once the date is selected, I'd like this to update a query (criteria for date column). Is there a simple way to do this without having to use code?

Thanks!
Allison
 
Hi Allison

Could you post the SQL of the form it may provide some help and did you mean table rather than: "I'd like this to update a query"?
 
Hi,

Sorry for not providing more info...

I have a query called qry_SubFormSrc. This is the qry that runs a form called SalesForecast. There's one field in the query called Fcst_Date where I can enter in criteria to filter out specific months (i.e., Jan-07). So once this is filled in, the form would only populate data based on those dates.
Now I want the form to allow the user to select the month they want to look at. So if they choose Feb-07, then I'd like qry_SubFormSrc to change the date criteria to the month selected.
I hope I'm not making things commplicated. Perhaps I don't need the date criteria in the query at all and just select the dates in the combo box?
Hope that helps! (I'm fairly non-techie as you can tell!) :oP

Thanks!
Allison
 
in the sql you can set it like
Code:
UPDATE Table1 SET Table1.ContactName = [Forms]![frmContacts]![cboNewName]
WHERE
   (((Table1.ContactName)=[Forms]![frmContacts]![txtContactName]));

________________________________________________________
Zameer Abdulla
Help to find Missing people
Sharp acids corrode their own containers.
 
Thanks! It looks like it isn't too difficult... but can you help me understand where I need to do this. Sorry, I have everything working so far and have done this without m extensive knowledge of Access. Do I do this in the Form/On Update?
 
You can do it in the Click event of a command button as simple as below
Code:
Private Sub cmdUpdate_Click()
    Dim strSQl As String
    strSQl = "UPDATE Table1 SET Table1.ContactName = [Forms]![frmContacts]![cboNewName]"
    strSQl = strSQl & " WHERE   (((Table1.ContactName)=[Forms]![frmContacts]![txtContactName]));"
    DoCmd.RunSQL (strSQl)
End Sub

________________________________________________________
Zameer Abdulla
Help to find Missing people
Sharp acids corrode their own containers.
 
Hi, I think I'm a moron... :oP

I still can't get this to work. When I used the code above, I ended up getting an error msg. But now I'm 'trying another approach and think I'm almost there..!

In my query, the field FcstDate is the information I'm trying to limit. So in the criteria, I've entered:

=[Forms]![SalesForecast]![SelectDate]

When I run the query, this is correct and prompts me to enter a date (i.e., Jan-07), and the result is what I'm expecting.

So instead of manually running the query, I have a combo box that is used to select the date [SelectDate]. How do I get this to link to the query so that it updates my Subform data?

Thanks again,
Allison
 
Thanks! I'v'e got it now...!! But now have posted a separate message with somewhat related issue..!

Thanks for the help!
Allison
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top