My Assistant
![]() ![]() |
|
|
Apr 3 2012, 08:51 AM
Post
#1
|
|
|
UtterAccess Enthusiast Posts: 56 |
Access 2010
Hello all, again I seek assistance. (IMG:style_emoticons/default/smile.gif) I would like to have a button on my Form that once clicked the current Record is copied, but I'd like two fields 'EventDate' and 'Status' fields to be cleared on the duplicate Record... What would be the best way to code this? As usual -any help, advice etc. greatly appreciated! |
|
|
|
Apr 3 2012, 09:28 AM
Post
#2
|
|
|
UtterAccess Ruler Posts: 2,657 |
CODE Private Sub CopyRecordl_Click() DoCmd.RunCommand acCmdSelectRecord DoCmd.RunCommand acCmdCopy DoCmd.GoToRecord , , acNewRec DoCmd.RunCommand acCmdPaste Me.EventDate = Null Me.Status = Null End Sub Linq ;0)> This post has been edited by missinglinq: Apr 3 2012, 09:28 AM |
|
|
|
Apr 3 2012, 10:22 AM
Post
#3
|
|
|
UtterAccess Enthusiast Posts: 56 |
|
|
|
|
Apr 3 2012, 10:26 AM
Post
#4
|
|
|
UtterAccess VIP / UA Clown Posts: 25,041 From: LI, NY |
I would be more inclined to use SQL
CODE Dim strSQL As String
strSQL = "INSERT INTO table (field List) " & _ "VALUES(" & Control & ", " & control etc. CurrentDB.execute strSQL, dbFailOnError |
|
|
|
Apr 3 2012, 11:26 AM
Post
#5
|
|
|
UtterAccess Ruler Posts: 2,657 |
I would be more inclined to use SQL Why, pray tell? Say you've got a Record with 12 Fields, and you want all except 2 Fields duplicated, why would you go to the trouble of using an insert and having to innumerate thru 10 Fields? Also, while doing an INSERT like this, the New Record will be created, but the user will not be taken to the New Record in order to fill in the other two Fields; this is always, in my experience, a requirement for this type of task. Linq ;0)> This post has been edited by missinglinq: Apr 3 2012, 12:09 PM |
|
|
|
Apr 3 2012, 02:55 PM
Post
#6
|
|
|
UtterAccess VIP / UA Clown Posts: 25,041 From: LI, NY |
The why is because you can control EXACTLY what gets copied. If you are copying 10 of 12 fields, then your database is probably not normalized properly and you have other issues. The more fields you have, especially the more you are duplicating, the more likely a normalization problem.
|
|
|
|
Apr 3 2012, 03:32 PM
Post
#7
|
|
|
UtterAccess Ruler Posts: 2,657 |
The why is because you can control EXACTLY what gets copied. And how does the code I posted not "control EXACTLY what gets copied?" I'm sorry but that reasoning simply doesn't wash! And trying to obfuscate the issue with talk of normalization problems isn't going to justify it either! The vast majority of people who post questions here have no idea what a SQL statement is, and would most likely be uncomfortable using one. You're certainly entitled to your opinion, but keep in mind that 95% or more of the time we're dealing with newbies, here, and things should be kept as simple as possible. And other issues, not germane to the discussion, like normalization, only tends to confuse newbies. And as I said, when using your INSERT statement the user would still be faced with the problem of locating the New Record in order to complete it! Linq ;0)> This post has been edited by missinglinq: Apr 3 2012, 03:36 PM |
|
|
|
Apr 3 2012, 03:47 PM
Post
#8
|
|
|
UtterAccess VIP / UA Clown Posts: 25,041 From: LI, NY |
Linq
No offense, but how many posts do you have here and how many do I have? You certainly have some valid points about your method as opposed to mine and I don't dispute that. But please don't presume to tell me about what level the people here have or how we should dumb down the responses for them. You insult me and them when you do so. You want to debate the merits of a suggestion, feel free to do so. But don't instruct me on how to answer questions. Learning and becoming familiar with SQL opens a great deal of power and flexibility for users of Access. So not showing them SQL because you think they can't handle it is doing them a disservice. As I said, copying records except for a couple of fields indicates a problem with design. |
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 21st May 2013 - 02:42 AM |