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

DoMenuItem or RunCommand?

Status
Not open for further replies.

handlebarry

Technical User
Dec 21, 2004
118
0
0
GB

I have a simple form with a text box and a combo box outputting to one table. User fills in text box, choses from combo box and then clicks on a command button to save record (acNewRecord). Currently both fields clear after saving. What I'm trying to do is keep what the user has entered into text box for all subsequent records.

I have found the following solution from earlier threads but cannot get it to work.

'Select record
'DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
'copy record
'DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
'Paste Append
'DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70

' Then delete the fields you don't want
'Me!Name = ""
'Me!Address = ""

In Access 2000 should I be using RunCommand instead, if so can anyone advise how. Is this the ideal solution to this at all?

thanks
 
s'ok i have the solution:

DoCmd.RunCommand acCmdSave
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdCopy
DoCmd.RunCommand acCmdPasteAppend

"combobox" = Null

this does however create a extra record (without the data from combo box) on exiting the form!
 
Except, I think the acCmdSave goes for design changes of the object (here, the form), not the current record. Try for instance:

[tt]docmd.runcommand accmdsaverecord[/tt]

Roy-Vidar
 
Hi
Microsoft recommends RunCommand:
Code:
For: DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
Use: DoCmd.RunCommand acCmdSelectRecord
For: DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
Use: DoCmd.RunCommand acCmdCopy
For: DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste Append
Use: DoCmd.RunCommand acCmdPasteAppend

I would find it easiest to do something like this:
Code:
Private Sub TextBox_AfterUpdate()
Me.TextBox.DefaultValue = """" & Me!TextBox.Text & """"
'Take the comment off the next line, to see what is happening
'MsgBox Me.TextBox.DefaultValue
End Sub
Which would carry the data in TextBox forward to a new record.
 
thanks have changed to save record

this still produces an extra record though, which also happens if I comment out the save command completely??

think I will try an IIf IsNull statement somewhere
 
thanks working on both solutions

with the default value solution will this mean the default value is always the same or will it always be the text that the user enters after opening form?
 
Hi
The default value will change every time the user changes the information in the textbox.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top