Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access 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 February 14th, 2008, 12:03 PM
Authorized User
 
Join Date: Feb 2008
Location: , , .
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default Database, VBA programming

http://www.flickr.com/photos/2381306...n/photostream/ is a subform which shows Parts.Select checkbox of those parts which I want to see their History.May choose > 1.Then click the commandButton.Should show up History Forms.Both forms' common fields are "PartsID".PartsID in History Form is not unique for every record.http://www.flickr.com/photos/2381306...n/photostream/
But,when parts138,139 are checked & cursor happened to be at 136, History of 138 dont show up after icon is clicked.But I want thm to show up http://www.flickr.com/photos/2381306...n/photostream/


How should the codes be written? Can anyone enlighten me? Thanks.



 
Old February 14th, 2008, 01:15 PM
Friend of Wrox
 
Join Date: Jan 2005
Location: Kansas City, Missouri, USA.
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default

Camehere,
Do you have the code behind the commandbutton?


dartcoach
 
Old February 14th, 2008, 01:15 PM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

What does the code currently look like? If you are using checks to check the records you want to see the history of, then I would use a query string where Check = Yes, like:

"SELECT * FROM tblHistory WHERE MyCheck = Yes"

This assumes that the check boxes are bound, and there is a check field in each record.

Then after the report runs, run an update query that sets all the checks to No so that the form is cleared.



mmcdonal

Look it up at: http://wrox.books24x7.com
 
Old February 14th, 2008, 08:51 PM
Authorized User
 
Join Date: Feb 2008
Location: , , .
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you for all your replies
My code for the commandbutton is something like that. It only shows up the History of the Part which the cursor is resting at.

And History of all selected parts have to show up in a form.

stDocName = "frmHistory"
    stLinkCriteria = "[PartsID]=" & "'" & Me![PartsID] & "'" _
& "Chkbox=" & "'" & True & "'"

    DoCmd.OpenForm stDocName, , , stLinkCriteria

 
Old February 14th, 2008, 09:27 PM
Authorized User
 
Join Date: Feb 2008
Location: , , .
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Or something like that?

stDocName = "frmHistory"
    stLinkCriteria = "[PartsID]=" & "'" & MouldPartsDetails![PartsID] & "'" _
& "In (Select PartsID From MouldPartsDetails Where Chkbox = True)"

    DoCmd.OpenForm stDocName, , , stLinkCriteria

 
Old February 15th, 2008, 05:21 AM
Authorized User
 
Join Date: Feb 2008
Location: , , .
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hey I got the part on the opening History of selected part, I used Query.. but I need to reset checkbox to false... any advices?

 
Old February 15th, 2008, 10:04 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Create an Update Query that sets all the check boxes to False / No, then do this in your code:

DoCmd.SetWarnings False
DoCmd.OpenQuery "MyUpdateQuery"
DoCmd.SetWarnings True



mmcdonal

Look it up at: http://wrox.books24x7.com
 
Old March 4th, 2008, 01:27 PM
Authorized User
 
Join Date: Feb 2008
Location: , , .
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Table A: PartName, Code
Table B: PartName, Date

My FormB is created based on Table B fields, recordsource of form is from Table B. I need to add another textbox and its controlsource should be 'code' in Table A. I am not using subform. how should the SQL for controlsource be like?


Thanks.
 
Old March 4th, 2008, 01:50 PM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

It should look like this:

Table A:
PartID - PK
PartName

Table B:
CodeID - PK
PartID - FK
Code
Date

This will get you what you want and make it updateable.

Alternatively, you can create an unbound ListBox (not sure if this is one to one, or one to many), and then display the value using the On Current event of the form and a Me.ListBox.Recordsource = "SELECT [Code] FROM TableA WHERE [PartName] = '" Me.PartName kind of thing.

This will DISPLAY the data, but you can't update it without adding more code, and perhaps another button to update the field.

Did that help?

mmcdonal

Look it up at: http://wrox.books24x7.com
 
Old March 4th, 2008, 09:40 PM
Authorized User
 
Join Date: Feb 2008
Location: , , .
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry I am very bad at Access…

For my TableA, each partname has a unique Code number. And my code is tied to the partname, fixed and needs not be changed My tableB, has comboboxes partname and date. FormB is based on TableB. A textbox has been added at each record , which I want it to appear as code, matched by the partname in TableA, where partname is same as combobox partname.
Whenever I change combobox partname in a record, the textbox showing code should change accordingly.

I tried setting SELECT [Code] FROM TableA WHERE [Partname] = Me.combo64 in the property setting controlsource




Similar Threads
Thread Thread Starter Forum Replies Last Post
Database Programming fogunsakin VB Databases Basics 1 April 25th, 2008 04:35 PM
Where do I start my database programming in C#? Crazy4C C# 2 April 20th, 2006 05:03 AM
VBA programming of "Get External Data" John Hollingsworth Excel VBA 2 August 2nd, 2005 10:02 PM
Need Help Programming a Date Comparison Database jackson_jl Beginning VB 6 0 March 7th, 2005 03:03 PM





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