Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 7th, 2006, 05:18 PM
Registered User
 
Join Date: Jan 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help with VB/Queries

I hope someone can help me. I need help running a query through my forms that will display the results in a text box on the same form...Here is my situation...

I have a calendar made up of buttons(one for each day).Click on a date it will display events that were taken from another table in a text box below the calendar.... I wouldnt mind even having a subform with that information.

How can i write in VB to query that table and take the results and display then in a text box below or even make subform with the results.


Please help.
 
Old January 9th, 2006, 11:26 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Welcome to P2P, Jennifer!

I assume the other table has a list of events (e.g. tblEvents), and in that table there is an event date field (e.g. dtmEventHeld).

Suppose you used a subform that lists the events (e.g. sfrEvents) and a date button for each day of the month (e.g. cmdDate1, cmdDate2, etc.). In the main form's date button ON CLICK event, you can put something like this:

Me.sfrEvents.SourceObject = "SELECT * FROM tblEvents WHERE [dtmEventHeld] = #" & Me.cmdDate1 & "#"



Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
 
Old January 9th, 2006, 11:33 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Oops... that should read

Me.sfrEvents.SourceObject = "SELECT * FROM tblEvents WHERE [dtmEventHeld] = #" & dtmDate & "#"

Where dtmDate is a date that is compiled when you click a specific button (e.g. cmdDate) on the main form. For example, if you click the "1" button on the mainform then you'd have to figure out which month, day, and year you're talking about and then assign it to the date dtmDate using the DateSerial function.

Dim dtmDate as Date

dtmDate = DateSerial(YYYY, MM, DD)

YYYY, MM, DD are the parts of the date you "collected" when you clicked that button. If the button said "1", then DD = 1. I don't know enough about what your form looks like to guess how you express what date you're sitting on.


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
 
Old January 9th, 2006, 11:56 AM
Registered User
 
Join Date: Jan 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

So I should put this all in the VB for the onclick event?

 
Old January 9th, 2006, 12:15 PM
Registered User
 
Join Date: Jan 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Here is what I have... I have a home made caledar with button named 1_1_2006, etc... This is on one form. I have added a subform called Date_Req. This has all of my events. When I click on 1_1_2006 I want the subform to just show events for that day. I hope this helps.






Similar Threads
Thread Thread Starter Forum Replies Last Post
simple MSSQL queries and VB.NET bluHatter ASP.NET 2.0 Basics 34 September 6th, 2007 03:24 PM
Combining Queries or results from 2 queries Ford SQL Server 2000 24 November 7th, 2005 08:54 PM
Access and Excel Queries in VB Mihai B Access VBA 1 January 24th, 2005 08:40 AM
combine 2 queries collie SQL Server 2000 2 November 29th, 2004 03:09 PM
Queries xzvi0r Access 5 September 8th, 2003 10:03 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.