Normal Topic Specialized "search" (Read 17889 times)
SpencerWulwick
Senior Member
Members
*****
Offline



Posts: 677
Location: Wilton Manors, Florida
Joined: Jan 16th, 2005
Specialized "search"
Feb 5th, 2005 at 5:13am
Print Post Print Post  
My database frequently has 2 records per household: a "Main" record for one of the adults and a "Companion" record for his/her spouse.

When I'm working (in search/update mode) on one of the records, I want to be able to click on a command button to take me to the "alternate" record.

In other words, if I am in the Main record, I want to click on the command button to take me to the Companion record.  Likewise, if I am in the Companion record, I want the command button to take me to the Main record.  I want to be able to click and alternate between the two records as often as necessary.

For some reason, I cannot visualize an appropriate approach to doing this.

Suggestions will be appreciated.
  

- Spencer

    ** Practice random kindness & senseless acts of beauty!
Back to top
IP Logged
 
Steve_in_Texas
Senior Member
*****
Offline


No personal text

Posts: 893
Location: San Antonio
Joined: Feb 21st, 2004
Re: Specialized "search"
Reply #1 - Feb 5th, 2005 at 3:30pm
Print Post Print Post  
Are they both Parent records or is one a subrecord of the other?

Are they records in 2 different forms?

If so, I think you can just open the two records at the same time and bounce between them using the windo tabs at the bottom of the screen.


Steve
  
Back to top
IP Logged
 
SpencerWulwick
Senior Member
Members
*****
Offline



Posts: 677
Location: Wilton Manors, Florida
Joined: Jan 16th, 2005
Re: Specialized "search"
Reply #2 - Feb 5th, 2005 at 4:13pm
Print Post Print Post  
Hi Steve -

I'm sorry for not being more specific.  No, one is not a subform of the other.  

The database only has one form (which consists of 6 tabs).  I need every item of all 6 tabs for each of the individuals.  (I had considered sub-forms but it would not work in this instance).  

When I am looking at the information about one of the spouses, I almost always need to access the same information about the other.

Perhaps if I shared my solution in Access, it might generate some ideas for a Sesame solution.

I use 2 fields (layout elements) on each form to accomplish what I want.  One field is ID (a unique system generated "number").  The other field is Alt ID.  So, if one person's record was ID number 63 and the other persons ID number was 104, each record would "point" to the ID number of the other record in the Alt ID field.

In other words, the record with ID number 63 would show an Alt ID of 104.  The record with ID number 104 would show an Alt ID of 63.

The command button was programmed:

Private Sub FindCompanionForm_Click()
On Error GoTo Err_FindCompanionForm_Click

   Dim stDocName As String
   Dim stLinkCriteria As String

   stDocName = "frmContact"
   
   stLinkCriteria = "[Alt ID]=" & "'" & Me![ID] & "'"
   DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_FindCompanionForm_Click:
   Exit Sub

Err_FindCompanionForm_Click:
   MsgBox Err.Description
   Resume Exit_FindCompanionForm_Click
   
End Sub


I hope that this better defines what I am attempting to do.

If at all possible I would like to do it using Sesame's built-in commands rather than basic programming.  One of the problem for me with basic programming is that I do not retain the language when I am away from it for even brief periods.  
  

- Spencer

    ** Practice random kindness & senseless acts of beauty!
Back to top
IP Logged
 
Steve_in_Texas
Senior Member
*****
Offline


No personal text

Posts: 893
Location: San Antonio
Joined: Feb 21st, 2004
Re: Specialized "search"
Reply #3 - Feb 5th, 2005 at 4:32pm
Print Post Print Post  
Well, if you only have 1 form, then my guess is that you will need to load the Alt ID into memory via globalvalue(), then go into search mode, then retrieve the globalvalue and put it into the proper LE to perform a new search.
Then do the same thing in reverse to go back to the record you were on originally.

Something like:

On element Entry of a command button:

if Alt ID <> "" then globalvalue("vAltId",Alt ID)
nn = @selecttreeitem("Search Update Menu!Search (F7)")
ID = @globalvalue("vAltId")
nn = @selectreeitem("Search Menu!Search Commands!Retrieve New Results (F10)")


Basically, globalvalue will retain the ID number while you close the form and do a different serach. I think the command button will 'bounce' you back and forth between these records.

Antoher option is to just pop up the writeln window with a 'summary' of the data from the Alternate window. You coul use:

If Alt ID <> "" then vstring = @xlookupsourcelist(@FN, Alt ID, "ID", "Firstname,lastname,address,phone,etc"

Then use the @stringarray commands or simply "Split" the info into the writeln window. (should be rather simple to do.

The above code has not been tested so it may need to be tweaked, and some error checking needs to be put in place.

I'm planning to do something similar this weekend, so if anyone else has any thoughts, please post.

Thanks,

Steve




  
Back to top
IP Logged
 
SpencerWulwick
Senior Member
Members
*****
Offline



Posts: 677
Location: Wilton Manors, Florida
Joined: Jan 16th, 2005
Re: Specialized "search"
Reply #4 - Feb 5th, 2005 at 6:01pm
Print Post Print Post  
Steve -

Using the writein window is not a viable alternative for me - because I frequently want to actually work with the record, make changes etc.  "Bouncing" back and forth between the two is precisely what I want.

I am, therefore, trying to work with your "on element entry" code for the command button, which seem promising.

Since you say you may be doing something similar and just in case you copy/paste your code, I want to point out that there is a typo in line 4 where you say "nn = @selectreeitem"  It should read "nn = @selecttreeitem"  Again, I'm only pointing this out in case you decide to copy and paste.

Now, the code is not working; however, I have a feeling what might be causing the problem.  First, I do not know what "nn" means.  Coicidentally I have a labout element named "NN" (for nickname).  Something tells me that is creating the problem.

Can you further explain what the nn stands for .... or how to get around the conflict with the element name?

Also, I am a complete novice when it comes to "error checking", so if you could suggest language for that, it would be a big help.

I can conceptualize the programming (even if I don't fully understand it) so I think it will do the trick nicely, with a little tweaking (as you say).

Getting this flat will be greatly appreciated.  Thanks!
  

- Spencer

    ** Practice random kindness & senseless acts of beauty!
Back to top
IP Logged
 
Steve_in_Texas
Senior Member
*****
Offline


No personal text

Posts: 893
Location: San Antonio
Joined: Feb 21st, 2004
Re: Specialized "search"
Reply #5 - Feb 5th, 2005 at 6:31pm
Print Post Print Post  
becuase you have an LE named NN, it should be changed to something else, in your case. Try this:

var Z as int

z = @SelectTreeItem("xxx")

(where xxx is the menu option you want to run.)

You can search for @selectTreeItem to see how to use error checking properly (I'm not very good at it.)

Also, you may need to add the command to save the record before going to Search Mode. (just insert another @SelectTreeItem command to "Save Record". Make sure the commands are spelled EXACTLY as they appear in the menu tree, otherwise you will get an error or it will not work.

Here's a good thread that taught me a lot about saving and exiting a form using @selectTreeItem.

http://www.lantica.com/Forum2/cgi-bin/yabb/YaBB.pl?board=archived;action=display...

ps. put some 'writeln' here and there to make sure it's doing what its supposed to. Such as:

writeln("Globalvalue = " +@globalvalue("Alt ID"))

Let us know how you do.

Steve






  
Back to top
IP Logged
 
Steve_in_Texas
Senior Member
*****
Offline


No personal text

Posts: 893
Location: San Antonio
Joined: Feb 21st, 2004
Re: Specialized "search"
Reply #6 - Feb 5th, 2005 at 6:38pm
Print Post Print Post  
2 more thoughts:

If you are running in a Client/Server setup, perhaps you could open a second instance of Sesame and bounce between the two programs. (seems kind of sloppy to me)

Or

Create a copy of your form within the same database. Make a minor change to the form (maybe just change the color of the form) and then you can have both forms open at the same time. Bouncing between the two by simply clicking on the tabs at the bottom of the page. (Similar to how you can have Add Data mode AND Search/Update Mode open at one time) This will then allow you to copy and paste between the two or use programming to 'post' data from one form to another using the Formfieldvalue() command.

Steve
  
Back to top
IP Logged
 
SpencerWulwick
Senior Member
Members
*****
Offline



Posts: 677
Location: Wilton Manors, Florida
Joined: Jan 16th, 2005
Re: Specialized "search"
Reply #7 - Feb 5th, 2005 at 9:17pm
Print Post Print Post  
Steve -

You wanted me to let you know how I did .... I DONE GREAT!  sooooo ... thank you so very much.

I'm not sure that I did the "error checking" right (I chose to use the @msgbox) but it works like a charm and I'm happy as a pig in (whatever it is that a pig is happy in)     Smiley

Here's the final On-element-entry programming for the Command Button to "Get The Companion Record."

var Z as int

if Alt ID0 <> "" then
{
globalvalue("vAltId",Alt ID0)
z = @SelectTreeItem("Search Update Menu!Navigation!Save Record")
z = @selecttreeitem("Search Update Menu!Search (F7)")
ID = @globalvalue("vAltId")
z = @selecttreeitem("Search Menu!Search Commands!Retrieve New Results (F10)")
}
else
@msgbox("","There is no Companion Record","")

Also, since I usually prefer to work with my database in search mode with all forms "open," I have another command button to "Return to all Records"

The On-element-entry programming for that Command Button is:

var Z as int
z = @SelectTreeItem("Search Update Menu!Navigation!Save Record")
z = @selecttreeitem("Search Update Menu!Search (F7)")
z = @SelectTreeItem("Search Menu!Clear Form (F3)")
z = @selecttreeitem("Search Menu!Search Commands!Retrieve New Results (F10)")

  

- Spencer

    ** Practice random kindness & senseless acts of beauty!
Back to top
IP Logged
 
Steve_in_Texas
Senior Member
*****
Offline


No personal text

Posts: 893
Location: San Antonio
Joined: Feb 21st, 2004
Re: Specialized "search"
Reply #8 - Feb 5th, 2005 at 9:22pm
Print Post Print Post  
Nice!

Isn't this fun?

Smiley

Steve
  
Back to top
IP Logged
 
SpencerWulwick
Senior Member
Members
*****
Offline



Posts: 677
Location: Wilton Manors, Florida
Joined: Jan 16th, 2005
Re: Specialized "search"
Reply #9 - Feb 6th, 2005 at 7:16am
Print Post Print Post  
I found a "flaw" in the on-element-entry programming for my Command Button to find a companion record.

When I accessed all records in a database and navigated to any particular record, the command button worked fine either taking me to the companion record or giving me a voice message that no companion record exists.

If, however, I did a search (F7) to a particular record and then, when I got to the desired record, executed the command button, it failed.  The reason is that "garbage" was still left in the retrieve spec.

All I had to do was add a SelectTreeItem to Clear the form.  Here's the revised programming. 

var Z as int

if Alt ID <> "" then
{
globalvalue("vAltId",Alt ID)
z = @SelectTreeItem("Search Update Menu!Navigation!Save Record")
z = @selecttreeitem("Search Update Menu!Search (F7)")
z = @selecttreeitem("Search Menu!Clear Form (F3)")
ID = @globalvalue("vAltId")
z = @selecttreeitem("Search Menu!Search Commands!Retrieve New Results (F10)")
}
else

z = @asynchshell("C:\Program Files\Sesame\Data\Sounds\No Record.wav")

I remembered that you said you might be doing something similar over the week-end so I just want you to have whatever info might be helpful.
  

- Spencer

    ** Practice random kindness & senseless acts of beauty!
Back to top
IP Logged