Kamis, 26 Maret 2015

Re: [MS_AccessPros] VBA code to call specific record in a form

 

Afiqah-

What exactly is it asking you for in the dialog box? What is the Record Source of frmModelSpecification (the SQL if a query)?

John Viescas, Author
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications
SQL Queries for Mere Mortals
http://www.viescas.com/
(Paris, France)

On Mar 26, 2015, at 8:36 AM, afiqah afiq bubbleblue_007@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:

John,Thank you for your help. It works! :D
One more problem is before it opens the form frmmodelspecification, enter parameter value dialog box is invoked. which I need to type the model name to open the form like I want. how to skip this enter parameter value dialog box?

Regards,Afiqah

On Wednesday, March 25, 2015 5:37 PM, "John Viescas JohnV@msn.com [MS_Access_Professionals]" <MS_Access_Professionals@yahoogroups.com> wrote:

Afiqah-
Using command buttons is a bad idea. As Bill pointed out earlier, that would force you to change your form design every time you added a new model. What you need is a combo box and a command button. The Row Source needs to look something like:
SELECT ID, ModelName FROM tblmodelspecification ORDER BY ModelName;
You will need to use the actual name of the field in tblModelspecification that has the model name - I just guessed at "ModelName".
Set the Bound Column to 1, Column Count to 2, and Column Widths to 0";1.5"
Name the combo box cboModel.
In the Click event of the command button, run your OpenForm action.
Where Condition: [ID] = [Forms]![frmHome]![cboModel]
You can open it in Read Only or Edit mode - your choice.
John Viescas, AuthorMicrosoft Access 2010 Inside OutMicrosoft Access 2007 Inside OutMicrosoft Access 2003 Inside OutBuilding Microsoft Access Applications SQL Queries for Mere Mortals http://www.viescas.com/ (Paris, France)

On Mar 25, 2015, at 5:01 AM, afiqah afiq bubbleblue_007@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:
hi John & Duanne!
let me reconstruct my question. :)
1) I have created a table tblmodelspecification, consist of 37 fields. ID is Primary field and the records stored are ( Ford Fiesta, Ford Focus, VW Polo and etc.)
2) Based on tblmodelspecification, I created a form frmmodelspecification that displays all 37 fields for one record only. By default, when I change it to form view, it will display the first record data which is Ford Fiesta.
3)I also created another form frmHome. This form is under unrelated object section. I have changed the label to button controls where I have number of buttons same as number of records. I named the button as Ford Fiesta, Ford Focus, VW Polo and etc.
4) The situation is I want the user to choose a button among buttons in frmHome. If the user click on Ford Fiesta button, the program will open frmmodelspecification and displays Ford Fiesta record.
5) my question is how to create events to fulfil the above situation?
I have tried to create an event for Ford Fiesta button. I used macro builder. Action: OpenFormFrom Name: frmmodelspecificationView: FormFilter name:Where Condition: [ID]=[Forms]![frmmodelspecification]![ID]Data Mode: EditWindow Mode: Normal
The result is when I set Data Mode to read only, the output is just a blank white screen and when I set Data Mode to Edit, the output is frmmodelspecifation form is open without any records appear. Images and labels are appeared in the form.
hmm..sorry, I'm truly a Ms Access beginner. Hope you can guide me.
Thank you!
Regards,Afiqah

On Wednesday, March 25, 2015 3:30 AM, "John Viescas JohnV@msn.com [MS_Access_Professionals]" <MS_Access_Professionals@yahoogroups.com> wrote:

My bad. Yes, stand-alone labels have a few events, including Click and Dbl Click.
John Viescas, AuthorMicrosoft Access 2010 Inside OutMicrosoft Access 2007 Inside OutMicrosoft Access 2003 Inside OutBuilding Microsoft Access Applications SQL Queries for Mere Mortals http://www.viescas.com/ (Paris, France)

On Mar 24, 2015, at 8:22 PM, Duane Hookom duanehookom@hotmail.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:
"Stand-alone" labels are the only ones that have events associated with them. Associated label controls pass the events to the parent control.

Duane Hookom, MVP
MS Access

To: MS_Access_Professionals@yahoogroups.com
From: MS_Access_Professionals@yahoogroups.com
Date: Tue, 24 Mar 2015 15:23:46 +0100
Subject: Re: [MS_AccessPros] VBA code to call specific record in a form

Duane-
Yes, that's true, but Afiqah implied these are just stand-alone labels. And when a label is associated, clicking it fires the click event of the attached control, not the label. John Viescas, Author
On Mar 24, 2015, at 2:26 PM, Duane Hookom duanehookom@hotmail.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote: John,
I thought label controls that are not the child of another control can click, double-click, and mouse events.

I would try to avoid hard-coding model names as label captions on a form. This would mean having to change form designs as you add or remove models.

Duane Hookom, MVP
MS Access

From: MS_Access_Professionals@yahoogroups.com

Afiqah- Label controls don't have any events, so I don't see how you're going to make this work. Why not use Command Buttons and the Click event? In the respective events, use DoCmd.OpenForm with a filter specified in the WhereCondition parameter to display the record.John Viescas, AuthorOn Mar 24, 2015, at 2:34 AM, bubbleblue_007@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote: Hi,
I'm using Ms Access 2007.

Currently, I have designed a form (frmHome) consist of 10 labels which I named it lblFordFiesta, lblFordFocus, and etc.

I would like the user to open another form named frmmodelspecification that display Ford Fiesta record (display all fields) when the user click on lblFordFiesta and display Ford Focus record (display all fields) when the user click on lblFordFocus.

Ford Fiesta and Ford Focus records are stored in tblmodelspecification and consist of 37 fields. frmmodelspecification is created based on tblmodelspecification table while frmHome is created and categorized as unrelated objects.

Hope you can guide me to write VBA code for this event.

Thanks in advance!

Regards,
Afiqah

#yiv0066459038 #yiv0066459038 -- #yiv0066459038ygrp-mkp {border:1px solid #d8d8d8;font-family:Arial;margin:10px 0;padding:0 10px;}#yiv0066459038 #yiv0066459038ygrp-mkp hr {border:1px solid #d8d8d8;}#yiv0066459038 #yiv0066459038ygrp-mkp #yiv0066459038hd {color:#628c2a;font-size:85%;font-weight:700;line-height:122%;margin:10px 0;}#yiv0066459038 #yiv0066459038ygrp-mkp #yiv0066459038ads {margin-bottom:10px;}#yiv0066459038 #yiv0066459038ygrp-mkp .yiv0066459038ad {padding:0 0;}#yiv0066459038 #yiv0066459038ygrp-mkp .yiv0066459038ad p {margin:0;}#yiv0066459038 #yiv0066459038ygrp-mkp .yiv0066459038ad a {color:#0000ff;text-decoration:none;}#yiv0066459038 #yiv0066459038ygrp-sponsor #yiv0066459038ygrp-lc {font-family:Arial;}#yiv0066459038 #yiv0066459038ygrp-sponsor #yiv0066459038ygrp-lc #yiv0066459038hd {margin:10px 0px;font-weight:700;font-size:78%;line-height:122%;}#yiv0066459038 #yiv0066459038ygrp-sponsor #yiv0066459038ygrp-lc .yiv0066459038ad {margin-bottom:10px;padding:0 0;}#yiv0066459038 #yiv0066459038actions {font-family:Verdana;font-size:11px;padding:10px 0;}#yiv0066459038 #yiv0066459038activity {background-color:#e0ecee;float:left;font-family:Verdana;font-size:10px;padding:10px;}#yiv0066459038 #yiv0066459038activity span {font-weight:700;}#yiv0066459038 #yiv0066459038activity span:first-child {text-transform:uppercase;}#yiv0066459038 #yiv0066459038activity span a {color:#5085b6;text-decoration:none;}#yiv0066459038 #yiv0066459038activity span span {color:#ff7900;}#yiv0066459038 #yiv0066459038activity span .yiv0066459038underline {text-decoration:underline;}#yiv0066459038 .yiv0066459038attach {clear:both;display:table;font-family:Arial;font-size:12px;padding:10px 0;width:400px;}#yiv0066459038 .yiv0066459038attach div a {text-decoration:none;}#yiv0066459038 .yiv0066459038attach img {border:none;padding-right:5px;}#yiv0066459038 .yiv0066459038attach label {display:block;margin-bottom:5px;}#yiv0066459038 .yiv0066459038attach label a {text-decoration:none;}#yiv0066459038 blockquote {margin:0 0 0 4px;}#yiv0066459038 .yiv0066459038bold {font-family:Arial;font-size:13px;font-weight:700;}#yiv0066459038 .yiv0066459038bold a {text-decoration:none;}#yiv0066459038 dd.yiv0066459038last p a {font-family:Verdana;font-weight:700;}#yiv0066459038 dd.yiv0066459038last p span {margin-right:10px;font-family:Verdana;font-weight:700;}#yiv0066459038 dd.yiv0066459038last p span.yiv0066459038yshortcuts {margin-right:0;}#yiv0066459038 div.yiv0066459038attach-table div div a {text-decoration:none;}#yiv0066459038 div.yiv0066459038attach-table {width:400px;}#yiv0066459038 div.yiv0066459038file-title a, #yiv0066459038 div.yiv0066459038file-title a:active, #yiv0066459038 div.yiv0066459038file-title a:hover, #yiv0066459038 div.yiv0066459038file-title a:visited {text-decoration:none;}#yiv0066459038 div.yiv0066459038photo-title a, #yiv0066459038 div.yiv0066459038photo-title a:active, #yiv0066459038 div.yiv0066459038photo-title a:hover, #yiv0066459038 div.yiv0066459038photo-title a:visited {text-decoration:none;}#yiv0066459038 div#yiv0066459038ygrp-mlmsg #yiv0066459038ygrp-msg p a span.yiv0066459038yshortcuts {font-family:Verdana;font-size:10px;font-weight:normal;}#yiv0066459038 .yiv0066459038green {color:#628c2a;}#yiv0066459038 .yiv0066459038MsoNormal {margin:0 0 0 0;}#yiv0066459038 o {font-size:0;}#yiv0066459038 #yiv0066459038photos div {float:left;width:72px;}#yiv0066459038 #yiv0066459038photos div div {border:1px solid #666666;height:62px;overflow:hidden;width:62px;}#yiv0066459038 #yiv0066459038photos div label {color:#666666;font-size:10px;overflow:hidden;text-align:center;white-space:nowrap;width:64px;}#yiv0066459038 #yiv0066459038reco-category {font-size:77%;}#yiv0066459038 #yiv0066459038reco-desc {font-size:77%;}#yiv0066459038 .yiv0066459038replbq {margin:4px;}#yiv0066459038 #yiv0066459038ygrp-actbar div a:first-child {margin-right:2px;padding-right:5px;}#yiv0066459038 #yiv0066459038ygrp-mlmsg {font-size:13px;font-family:Arial, helvetica, clean, sans-serif;}#yiv0066459038 #yiv0066459038ygrp-mlmsg table {font-size:inherit;font:100%;}#yiv0066459038 #yiv0066459038ygrp-mlmsg select, #yiv0066459038 input, #yiv0066459038 textarea {font:99% Arial, Helvetica, clean, sans-serif;}#yiv0066459038 #yiv0066459038ygrp-mlmsg pre, #yiv0066459038 code {font:115% monospace;}#yiv0066459038 #yiv0066459038ygrp-mlmsg * {line-height:1.22em;}#yiv0066459038 #yiv0066459038ygrp-mlmsg #yiv0066459038logo {padding-bottom:10px;}#yiv0066459038 #yiv0066459038ygrp-msg p a {font-family:Verdana;}#yiv0066459038 #yiv0066459038ygrp-msg p#yiv0066459038attach-count span {color:#1E66AE;font-weight:700;}#yiv0066459038 #yiv0066459038ygrp-reco #yiv0066459038reco-head {color:#ff7900;font-weight:700;}#yiv0066459038 #yiv0066459038ygrp-reco {margin-bottom:20px;padding:0px;}#yiv0066459038 #yiv0066459038ygrp-sponsor #yiv0066459038ov li a {font-size:130%;text-decoration:none;}#yiv0066459038 #yiv0066459038ygrp-sponsor #yiv0066459038ov li {font-size:77%;list-style-type:square;padding:6px 0;}#yiv0066459038 #yiv0066459038ygrp-sponsor #yiv0066459038ov ul {margin:0;padding:0 0 0 8px;}#yiv0066459038 #yiv0066459038ygrp-text {font-family:Georgia;}#yiv0066459038 #yiv0066459038ygrp-text p {margin:0 0 1em 0;}#yiv0066459038 #yiv0066459038ygrp-text tt {font-size:120%;}#yiv0066459038 #yiv0066459038ygrp-vital ul li:last-child {border-right:none !important;}#yiv0066459038

[Non-text portions of this message have been removed]

------------------------------------
Posted by: afiqah afiq <bubbleblue_007@yahoo.com>
------------------------------------

------------------------------------

Yahoo Groups Links

__._,_.___

Posted by: John Viescas <johnv@msn.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (11)

.

__,_._,___

Tidak ada komentar:

Posting Komentar