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

Data is not updated!! Methods of saving a Form's Record?? 1

Status
Not open for further replies.

waldemar

Programmer
Nov 15, 2001
245
DE
I need a way of saving the current Record in a Form without having to Requery it (Requery moves to first Recordset)...

I tried:

DoCmd.Save
DoCmd.RunCommand acCmdSave

With neither do I have access to the correct data.

The Situation: The AfterUpdate Event of a TEXTBOX calls a function that does some export-to-file-stuff. The Function does not refer to me.TEXTBOX.value since it is global, so I have to look it up. But whenever I do that (DLookup()), I keep getting the OLD data of the Textbox.

I tried the above commands like this

Private Sub strBankName_AfterUpdate()
DoCmd.Hourglass True
DoCmd.RunCommand acCmdSave <------
exportFunction ID
DoCmd.Hourglass False
End Sub

But ain't no good...
 
Hiya,

How about storing the key(s) of the record in global variable(s) and returning to the record that way?

The .bookmark method may also be useful - (I haven't used it, but it marks a record to return to, based on the key).

Hope it points you in the right direction.

No doubt you'll get more help - but it may help in the interim.

Regards,

Darrylle &quot;Never argue with an idiot, he'll bring you down to his level - then beat you with experience.&quot;
 
Good point, but that would be sort of a roundabout... also Bookmarks currently don't work in my Database (i get errors when trying to read/write), i guess this is due to rather complex queries in the background...

Im looking for a way to 1. edit some field 2. make sure the new value is stored in the database, so I can 3. access the values via DLookups or VBA Recordset Objects...

Interesting is also that the form controls have a method &quot;Requery&quot;... but no success with this one so far (anybody used this?)
 
Try:
DoCmd.RunCommand acCmdSaveRecord

It should work

Dan
 
Hi,

Are you using ID as criteria for dlookup() in your export function? If so, does it get changed when you change the bank name textbox? You mentioned you don't refer to strBank bnut that it is global so is this global variable being changed accordingly? It may not be the save but what your search criteria?

Have a good one!
BK
 
As I understand your situation, you have a module level function which needs the current value of the textbox so it looks in the tables, which aren't yet updated, for the value. A form control uses the property .Value to store the current value and the property .OldValue to store the previous value until the record is saved. This is not a common way of handling this situation but it is a reasonable approach. Pass a reference to the form itself to the function and extract the .Value from the control. You can then get the exact values of any of the controls you wish.

From the form class use the function:
Whatever = YourFunction(YourParameters, Me)

Public Function YourFunction(YourParameters, frm As Form)

Dim strValue As String
strValue = frm.strBlankName.Value
...

End Function ----------------------
scking@arinc.com
Life is filled with lessons.
We are responsible for the
results of the quizzes.
-----------------------
 
scking, reasonable Approach yes. Unfortunately directly passing a single value or the form reference to the function is not applicable, since that function (exportFunction()) is called from several forms (that's why it's on module level). Only solution would be to use &quot;Select Case&quot;, which makes this rather 'simple task' quite complex, I guess I will think about it...

&quot;Sometimes&quot; it helped when I did a Form.Refresh before calling the function... Why is real value not rewritten to the database when I use acCmdSave or similar (thanks danvlas)??

Blackknight, sorry, the real reference is of course me.ID.value and Yes, I use this value for further processing

 
DoCmd.Save [objecttype, objectname] saves the database object
The same thing happens with DoCmd.RunCommand acCmdSave

It's DoCmd.RunCommand acCmdSaveRecord that saves the record.

Regards,

Dan
 
aahhh!!! Thanks dan! I honestly did not notice there was a difference! acDmcSaveRecord should do the job ! :))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top