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

Continuos Form Question 1

Status
Not open for further replies.

cpsqlrwn

IS-IT--Management
Jul 13, 2006
106
US
I have a continuous modal form which is used for editing and deleting existng records. The form is called from a command button on a subform. Everything in the form works properly except that when there is only one item in the list I can't get it to save a change. There is only one editable field and when there are 2 or more records, using the <ENTER> key saves the record and sends the cursor to the next line. But when only 1 record exists, after I hit the <ENTER> key, the cursor sits in the editable field and the record selector shows it is still being edited. The record has not been updated. I don't really want to use a command button to accomplish this. Is there any alternative to this that I could use to have the change be saved when I hit the <ENTER> key while staying in the same field. Perhaps a code suggestion based on the recordcount being equal to 1? Or a requery routine? Hitting the <ENTER> key is not prompting any event. I'm not sure what events I can use since the field is not updating. I'm just not sure what to try. Thanks for any help!!
 
How are ya cpsqlrwn . . .

You can use the [blue]KeyDown[/blue] event of the lone textbox to capture the [blue]Tab[/blue] & [blue]Enter[/blue] keys and process saving this condition there.
Code:
[blue]   If Me.CurrentRecord = Me.Recordset.RecordCount Then
      If (Shift = 0 And KeyCode = 9) Or _
         (Shift = 0 And KeyCode = 13) Then
         If Me.Dirty Then Me.Dirty = False
         Me.Recordset.MoveFirst
      End If
   End If[/blue]
[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .
 
That is exactly what I was hoping to hear. I just wasn't familiar with capturing keystrokes. I'll give it a shot and see how it works. Thank you.
 
TheAceMan1....

Your suggestion worked like a charm. I have another question on a related subject. I have code elsewhere in this form to control movement from record to record and when I wrote that code, I used the RecordSetClone property. I know that this property copies all the records into memory for manipulation. This property also requires variable declaration. You used the RecordSet property which did not require a declared variable. Does this property work with the records as they exist in the form rather than copying an image of the records to memory? Also is there a preferred method, pros and cons? It seems like you can accomplish many of the same things with either approach. I have used the RecordSetClone property to perform looping calculations of several records. I don't think looping would work with the RecordSet property because you would be stuck on the current record. Is that true? Can you enlighten me a little?
 
cpsqlrwn . . .
Microsoft said:
[blue]Recordset Property:[/blue]

You can use the Recordset property to [blue]specify or retrieve[/blue] the ADO Recordset or [blue]DAO Recordset[/blue] object representing [blue]a form's record source[/blue].

The Recordset property returns the recordset object that provides [blue]the data being browsed in a form[/blue]. If a form is based on a query, for example, referring to the Recordset property is the equivalent of cloning a Recordset object by using the same query. [purple]However, unlike using the RecordsetClone property, changes made to the Form.Recordset property are automatically reflected in the current record of the form[/purple].

When a recordset is asked for in a Microsoft Access database (.mdb), a [blue]DAO recordset is returned[/blue], in a Microsoft Access project (.adp), an ADO recordset is returned.

This shows for starters that all forms are [blue]DAO![/blue]

So when you work with a Recordset [blue]you affect the form directly[/blue]. When you work with the Clone the form is untouched unless indirectly changed/updated by the clone.

As a typical example in looking up an ID and going to that record:

For the [blue]Clone[/blue] we have . . .
Code:
[blue]   rst.FindFirst "ID = 234"[/blue]
This is a lookup in the clone itself (form is untouched). When the clone record is found the clone's index & bookmark change to reflect the new record in the search. But thats all that happens. To bring the clone record into view in the forms recordset, bookmarks are used . . .
Code:
[blue]   Me.Bookmark = rst.Bookmark[/blue]
This where you see the form bring the record in view!

For the [blue]Recordset[/blue] we have . . .
Code:
[blue]   Me.Record.FindFirst "ID = 234"[/blue]
. . . and since [blue]Recordset[/blue] affects the form directly the record comes into view!

As far as looping is concerned, due to screen updates [blue]Recordset[/blue] [purple]takes a big performance hit[/purple]. But as you see, for the one time equivalent of going to a record it works great!

One of the [blue]Clones[/blue] greatest assets is allowing you to do all manner of things without touching the forms current state.

[blue]Your Thoughts . . .[/blue]

Calvin.gif
See Ya! . . . . . .
 
Thanks TheAceMan1....

I followed everything you said and I appreciate your taking the time to delve into the details. Over the last 3 months, you've been a lot of help to me in this project I have been developing!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top