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

datasheet view 3

Status
Not open for further replies.

hoofit

Technical User
Nov 20, 2005
343
US
Happy holidays,
Is there a way to display a command button in the datasheet view?

Thank you
 
How are ya hoofit . . .

The answer is no! I find alot of Excel officianado's get stuck with this view. Fact is [purple]you loose alot of form functionality[/purple] as a result ... aka the buttons you seek.

Be aware ... you can make a forms [blue]continuous view[/blue] look just like a spreadsheet and maintain full functionality. In this way you can have your buttons!

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

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
I, also mainly use continuous forms, but data sheet have there place. You can put your datasheet into a sub form on the main form. Then you can have buttons and other controls on the main form.
 
OK thank you. I will try some experimenting.....
 
Also sometimes helpful in Datasheet View forms is the fact that Textboxes have a Double-Click event that can be used to trigger code execution just like a Command Button.

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
All of this is very helpful. I like the appearance of the data sheet view with a few exceptions. The datasheet brings questions. Assume 5 records for this example.Whether a text box is used and coded as a command button or a command button itself is used, the button still shows up 5 times - once for each record - I'd prefer to see it once. Can the "cell borders" be modified - color change, thickness etc., and finally, in this view, can the "pointer" and the "asterisk" be removed?

hoof
 
My error - I mean't continuous form in the post .....
 
hoofit . . .

In that case the button needs to be in the forms Header or Footer.

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

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
My thoughts?
By golly it works. Nice finish. What a learning curve.

Thank you kindly

hoof
 
Also, when I was talking about using a Textbox DoubleClick event to trigger code, I didn't mean to have a Textbox just for that purpose, but rather to use the DoubleClick of one of the data entering/holding Textboxes that already exists.

Glad you finally found something that works for you!

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
OK, here's where I'm at. I'm using a continuous form and have 3 sample records. I've placed a delete record control button in the footer. Once the form is open, pressing the delete button deletes attempts to delete the first record. I have not made a selection. However, if I make a selection, everything is fine. So, the question is how do I prevent this from occurring (deleting a record without selecting it?)I want to delete a record by first selecting it as the one eligible for deletion, not one selected by Access. Here's the basic code for the button with a generic name

Private Sub Command26_Click()
On Error GoTo Err_Command26_Click


DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

Exit_Command26_Click:
Exit Sub

Err_Command26_Click:
MsgBox Err.Description
Resume Exit_Command26_Click

End Sub

Thank you kindly

hoof
 
hoofit . . .

[blue]DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70[/blue] is the same as [blue]selecting a Record[/blue].
[blue]DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70[/blue] performs the delete.

The above is ececuted against the currently selected record. When the form opens ... the currently selected record happens to be the 1st record (depicted by the record selector arrow. So the button is working correctly. Using the record selector you change the curent record.

Access uses DoMenuItem for backwards compatibility. I suggest you make the following changes"
Code:
[blue]Change:
   DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
   DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

To:
   DoCmd.RunCommand acCmdSelectRecord
   docmd.RunCommand acCmdDeleteRecord[/blue]


See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
AceMan1,
I tried your suggestion with the same results. A record is automatically selected with no user input. What I need is; When a user hits the delete button, nothing happens because a record has not been selected. At this point even a msgbox could appear as a prompt for the user to make a selection. I see this step as a preventive measure for a trigger happy user who may make an error by pressing buttons.

hoof
 
You can use a messagebox behind your Delete button asking if the user is positive that they want to delete the particular record, and only continue with the deletion if they click on Yes. This, by the way, is always a good idea when deleting records.

I'm in the middle of something right now but will check back and post some code if you need an example if you indicate that you need help.

Linq



The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
Where UniqueField identifies the record:

Code:
Private Sub cmdDelete_Click()
 Dim Msg, Style, Title, Response
 
 Msg = "Delete the Record for " & Me.UniqueField & "?"
 Style = vbYesNo + vbCritical
 Title = "Delete Selected Record"   

 Response = MsgBox(Msg, Style, Title)
 
 If Response = vbYes Then
  DoCmd.SetWarnings False
  DoCmd.RunCommand acCmdSelectRecord
  DoCmd.RunCommand acCmdDeleteRecord
  DoCmd.SetWarnings True
End If

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
Missingling,
I've got the following code to handle the msgbox issue. Problem is when the form opens, a record is already preselected. I would like to have nothing selected on load so the user 1) must make a selection then 2) confirm the deletion. Also, I'm trying to do this with no record selectors, I'd rather the selected record row highlited by the user.

Dim DeleteButtonDialogResult As Integer

DeleteButtonDialogResult = MsgBox("Are you sure that you want to delete this record?. This process is irreversible and all data will be permanently lost!.", vbYesNo + vbQuestion, "Delete?")
If DeleteButtonDialogResult = 6 Then '6 = a yes
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdDeleteRecord
End If


....and then some else statement here


hoof
 
hoofit . . .

As I said earlier:
TheAceMan1 said:
[blue]When the form opens ... the currently selected record happens to be the 1st record ... set by access.[/blue]
The best I can think of is to move your button code to the [blue]On DBL Click[/blue] event of one of the fields. At least this shows intentional selection for delete by the user.

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

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
There is no 'highliting a row' in Access, in the manner you're suggesting, unless you count selecting the row with the Record Selector! A bound form, which is what you're talking about, when displaying multiple records, will open with the first record in the recordset selected, as TheAceMan has said twice now! That's simply a fact of life. In order to not have this be so, the form would have to be Read-Only, which in turn would mean that there were no way to select a record for deletion.

The method that TheAceMan has suggested is actually one that I use in non-Single View forms. I think your choices here are really down to the way I've suggested or using the Double-Click event of one of your controls, as AceMan has suggested.


The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
OK, here's what I did. First (not shown) when the form loads I open to a new record, bypassing the first record issue. If a user presses the delete key, essentially nothing occurs in terms of record deletion and the usewr is then forced to make a conscious decision.I piggybacked the following code on the delete button as suggested by missingling to handle this.Unit ID will, of course be null as it is a new record. Make sense? What do you think? Thank you AceMan1, missingling and Majp for being patient. Pretty much what I was looking for but probably not explained as well as it should have been.

hoof


Private Sub PMAssignSub101DeletePM_Button_Click()
On Error GoTo Err_PMAssignSub101DeletePM_Button_Click

Dim DeleteButtonDialogResult As Integer

If IsNull(UnitID) = True Then
MsgBox "No record has been selected for deletion"

Else
DeleteButtonDialogResult = MsgBox("Are you sure that you want to delete this record?. This process is irreversible and all data will be permanently lost!.", vbYesNo + vbQuestion, "Delete?")
If DeleteButtonDialogResult = 6 Then '6 = a yes

DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdDeleteRecord
Else

End If

Exit_PMAssignSub101DeletePM_Button_Click:
Exit Sub

Err_PMAssignSub101DeletePM_Button_Click:
MsgBox Err.Description
Resume Exit_PMAssignSub101DeletePM_Button_Click

End If
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top