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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting Active Page on Dblclick event in a grid within a pageframe

Status
Not open for further replies.

VFP602

Programmer
Jan 23, 2002
41
MP
Hi guys! I have a pageframe that contains 2 pages. page 1 contains text boxes of my table fields. Page 2 contains a grid that lists all the records of the same table. What I want is when I double clicked on a record in a grid it should goes back to page 1 and display the values of the fields of the record. I already put the following in the double click event of my grid:
thisform.pageframe1.activepage=1
thisform.pageframe1.page1.refresh()
Double click works if I clicked on the blank row of the grid but not on the row with values. But it only the values of the first record is being displayed in page1. What I want is double click should only work in a non-blank row. Any ideas?
 
VFP602,
You have the code in the GRID's Click event, place the code instead in the "Textbox" click event for the first colum. If you have multiple columns, and you want people to be able to double click in any column, just put:

This.Parent.Parent.Column1.Text1.Click()

In their click event, so you don't have to repeat code in each text box. Then, it should work fine.

Best Regards,
Scott

Please let me know if this has helped [hammer]
 
Did you mean ... This.Parent.Parent.Column1.Text1.DblClick()
Yeah, it's working fine now Scott. Thanks a lot!
 
VFP602,
Haha... sorry about that.. I use "Single Click" method myself, and when I write it back out, I was just think'n MY way. :) Glad it's running for you now.
Best Regards,
Scott

Please let me know if this has helped [hammer]
 
This is still concerning my pageframe. On page 1, I have buttons to add,delete, edit and navigate records. This is a data entry screen for my chart of accounts table. Actually, I just copied this buttons from the one created by the Form Wizard from another form and pasted it on this page. I have text boxes for the fields in my table. Now, when a user creates the 'Add' button, program sets focus to a combox box with 4 choices. If user chooses one of the options, the program will do this:
if table is blank, i forced to append 'values' to the table like for ex.:
if option='Assets'
repl accno with '10001'
endif
otherwise, if table is not empty, and user chooses one of the options, program will get the last accno (account no.) and increments it by one and sends the value to Account no. textbox. My problem is, if for non-blank table and I clicked on 'Add' button, all my other text boxes are getting disabled and only my combo box is enabled. It just stays on the combo box. I already add :
thisform.pageframe1.page1.Txtboxname.enable=.T.
to all my text boxes but still they are all disabled.
Any idea?
 
Sorry, wrong word there. On my fifth sentence, it should read as ...when a user clicks ......
Sometimes, what we type is different from what we think...happens to me..
 
VFP602,
Well, this may be a little "confusing", but I'll explain a different approach...
What I do (and recommend you do...) is, create a sub-class of the textbox control (and combobox, and well, all controls, actually), but to stay focused here, in particular your textbox and combobox object. Then, in their "REFRESH" method, do the following:

This.Enabled = ThisForm.Editing

Also, you need to add an "EDITING" property to your form. This works whether you have it subclassed or not. Do this by clicking FORM, add Property. Then, in your EDIT & ADD buttons, set:

ThisForm.Editing = .T.

In your Save and Cancel buttons, set

ThisForm.Editing = .F.

After either call, issue:

ThisForm.LockScreen = .T.
ThisForm.Refresh()
ThisForm.LockScreen = .F.

This performs a nice, clean, behind the sceens, refresh of all objects on the form. With the Code that I mentioned above in your "Refresh" method for the text and combo box objects, it will fire "Automatically", and they will enable/disable automatically. I think this will make your life much simpler. It takes a little (very little) thought to be able to implement these things.
When you feel comfortable, I would recommend that you create a "BaseForm" that your base all your forms off of. (Set it up so that when you press "New Form" button, this is what you get, look under Tools, Options, Forms to set the "Default" FORM.)
Create a "Sub-class" baseform, and put the "Editing" property on the form, then all new forms you create will have this automatically. (In OOP terms, we call this "Inheritance"... Yes, you've heard the word, now you know how to use it...)
Good luck!

Best Regards,
Scott

Please let me know if this has helped [hammer]
 
I've tried what you told me Scott but I'm running into a problem right now and I'm running out of options. I already resolved the enabling/disabling of buttons.As previously mentioned, I have a combo box that lists 5 options when user clicks on the 'Add button'. Each option determines the succeeding account no. Ex. If user clicks on 'Assets', program looks for the last account no. in my 'last_given' field in my 'setupkey' table then increments that account no. and sends the value to the Account no. text box. So user actually does not need to input account no, it is being given automatically. Then, focus is set to the Account Name. My problem is if user clicks on 'Save' Button (it is the 'Add' button' on first click) only the account no. field is not being updated in the table. Also, in my setupkey table the account no. field is not being updated. It's blank. I have a public variable 'maccno' that receives the next account no. On the click event of my Add button, I put:

DODEFAULT()
SET PROCEDURE TO accproc
sele acccoa
maccno=space(5)
maccgroup=upper(alltrim;(thisform.pageframe1.page1.cbAccountGroup.value))
thisform.pageframe1.page1.TxtAccountNo.value=maccno
if used("setupkey")
sele setupkey
else
use setupkey in 0
sele setupkey
endif
set order to tag table_name
go top
IF mreccount=0
SEEK maccgroup
if found()
maccno=str(val(setupkey.first_key)+1)
endif
else
SEEK maccgroup
if found()
if empty(setupkey.last_given)
maccno=str(val(setupkey.first_key)+1)
else
maccno=str(val(setupkey.last_given)+1)
endif
endif
endif
sele setupkey
replace setupkey.last_given with maccno
sele acccoa
replace accno with maccno
thisform.pageframe1.page1.TxtAccountNo.value=maccno
SET PROCEDURE TO

Any help would be highly appreciated. Thanks.
 
VFP602,
A couple of quick things. If you are usuing Tabel or Row buffering, (and you have the type of buffereing set in the Data Environment for the specific table), you will need to issue a TABLEUPDATE() following the change. So, for your SETUPKEY, once you increment it, then issue: TABLEUPDATE.
So, in your code:
sele setupkey
replace setupkey.last_given with maccno
[red]TABLEUPDATE()[black]
sele acccoa
replace accno with [red]maccno[black]
thisform.pageframe1.page1.TxtAccountNo.value=maccno


As for your accno being set to blank, throw a trace on this code, and check the value of "maccno" (where I have marked it [red]red[black] as well), and see what it's actual value is. I assume that your "Save" button issues a "TABLEUPDATE()" on the selected table as well. Check the state of that value first. Also, remember that buffered records, before being saved have a negative record number, when tested against RECNO(). This may be causing you problems in your "REPLACE ACCNO WITH MACCNO" line, depending on where your record pointers are, and selected work area at the time of the "Replace". (So watch for that as well.)

Hope this helps some.
Best Regards,
Scott

Please let me know if this has helped [hammer]
 
Hi Scott!

I fixed all the bugs already. I did everything what you've told me. At first, I still get a blank 'maccno' eventhough I added the TABLEUPDATE already. Patiently, I put a trace on all my variables...checking step by step...and then I finally figured out what's really wrong.....(I almost bumped my head on the table after finding this out... ... call it stupidity...) It's because when maccno receives the value from the TxtAccno text box ...it is padded with spaces on the left side....that is....for ex.
when I input '10001' in the TxtAccno....what maccno gets is
' 10001'....so when I issue a replace command the field accno gets only the first 5 chars... So I just put alltrim ...that fixed the problem. I must have put my focused on some other things wherein I missed those small things....it happens.....I know I'm not the only one that experienced this....Anyway, thank you so much for your tips and ideas....really appreciate it...Now I am using my own class libraries and I owe it all to you. Many thanks!
 
Hi Scott!

I fixed all the bugs already. I did everything what you've told me. At first, I still get a blank 'maccno' eventhough I added the TABLEUPDATE already. Patiently, I put a trace on all my variables...checking step by step...and then I finally figured out what's really wrong.....(I almost bumped my head on the table after finding this out... ... call it stupidity...) It's because when maccno receives the value from the TxtAccno text box ...it is padded with spaces on the left side....that is....for ex.
when I input '10001' in the TxtAccno....what maccno gets is
' 10001'....so when I issue a replace command the field accno gets only the first 5 chars... So I just put alltrim ...that fixed the problem. I must have put my focused on some other things wherein I missed those small things....it happens.....I know I'm not the only one that experienced this....Anyway, thank you so much for your tips and ideas....really appreciate it...Now I am using my own class libraries and I owe it all to you. Just keep on doing the good work. Many thanks!
 
VFP602,
Well, if it's any consolation, I've been the victim of that (and have many head bumps to go with it...) myself! :) So, I can certainly sympathize...

Glad it's all working now.

Best Regards,
Scott

Please let me know if this has helped [hammer]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top