Good morning everyone:
I created a form and set the default view as a continuous form. Basically the form is displaying records in which the user can add or edit new ones. The record source for this form is a query that I built that is based on a table.
I have been working on this for several weeks and now I have been told that many times when a user wants to create a new record, much of the information that is displayed in a preexisting record is the same. Therefore, instead of rekeying in the same information (only making changes on a couple of the fields) they would like to copy the preexisting row and paste it into the “new” record row that is being displayed (the last row that is displayed) much like one would do in Excel.
Currently I have a before update event for writing new records: -
Private Sub Form_BeforeUpdate(Cancel As Integer)
-
'When a user is creating a new record the following code inserts the MonthID, YearID and
-
'The LocationsID. It does a Dlookup for the Locations ID when the control cboLocation is
-
'blank.
-
-
Dim frm As Form
-
Set frm = Forms!Forecast
-
-
If IsNull(frm![Binding_Percentage]) Then
-
MsgBox ("You need to select a Binding Percentage before you create a new record")
-
Cancel = True
-
Else: Cancel = False
-
End If
-
-
If Me.NewRecord Then
-
'If cboLocation is Not Null, grab the value from there
-
If Not IsNull(frm![cboLocation]) Then
-
JtnLocationsID = frm!cboLocation
-
YearID = frm!CboYear
-
MonthID = frm!CboMonth
-
Else 'Forms!Forecast![cboLocation] is Null
-
'Check and see if all 3 Controls have values in them
-
If Not IsNull(frm![cboDivision]) And Not IsNull(frm![cboWrkReg]) And _
-
Not IsNull(frm![cboCreditReg]) Then 'values in all 3 Controls
-
JtnLocationsID = DLookup("[JtnLocationsID]", "tblLocationsMM", "[DivisionIDFK] =" & frm![cboDivision] & _
-
" And [WrkRegIDFK] =" & frm![cboWrkReg] & " And [CreditRegIDFK] =" & _
-
frm![cboCreditReg])
-
YearID = frm!CboYear
-
MonthID = frm!CboMonth
-
Else
-
'no value in [cboLocation], and 1 or more values are missing in [cboDivision],
-
'[cboWrkReg], or [cboCreditReg]
-
-
MsgBox "1 or more values are missing in"
-
-
End If
-
End If
-
End If
-
End Sub
-
I played around and discovered that I could, using the mouse, right click in one of the rows and select “copy” and then right click in the last row (the new record line) and select “paste”. Actually this was pointed out to me by one of the people I am working with. What happens though, is that the paste action does not take and it creates a “blank” record of which I can then right click in that row (the newly created “blank” one) and paste again the info. Then it works. I say “blank” because it actually did create a record on my table with the YearID, MonthID, & JtnLocationsID via the above mentioned code. These are fields that are not in the displayed rows, hence why I created the code to write new records to the table.
Given the copy and paste mindset of my end user what would be the best approach to easily satisfy their desire to not have to rekey much of the information that is already in previously displayed rows? I am relatively new at this so don’t know what the best solution. One thing to mentioned is that this particular table does not have any fields where duplicates are not allowed. I guess that is one less issue to deal with.
Does anybody have ideas on how they would approach this?
Thanks,
Keith :-)
7 8677
Here's some sample code to carry selected values from an existing record into a new record, based on a command button placed in the header, but I suppose it could be in the footer. - Private Sub CopyPartialRecord2NewRecordButton_Click()
-
-
‘Assign field values to be carried forward to variables
-
MyFirstField = Me.FirstField
-
MySecondField = Me.SecondField
-
MyThirdField = Me.ThirdField
-
-
'Go to a new record
-
DoCmd.GoToRecord , , acNewRec
-
-
'Plug in old values from variables to new record
-
Me.FirstField = MyFirstField
-
Me.SecondField = MySecondField
-
Me.ThirdField = MyThirdField
-
-
End Sub
You can modify it to check for Null values before copying, if you desire.
Linq ;0)>
Linq:
In my continuous form, if I select a row a small arrow button displays in the far left. Actually, you can see this in the attached image. It does not for say highlight visually all the fields in the row. Does that arrow icon mean that it is highlighting all fields in that particular row so I can reference any of the fields via the code?
Thanks for the reply,
Keith.
Here's some sample code ............... ..... - Private Sub CopyPartialRecord2NewRecordButton_Click()
-
-
‘Assign field values to be carried forward to variables
-
MyFirstField = Me.FirstField
-
MySecondField = Me.SecondField
-
MyThirdField = Me.ThirdField
-
-
'Go to a new record
-
DoCmd.GoToRecord , , acNewRec
-
-
'Plug in old values from variables to new record
-
Me.FirstField = MyFirstField
-
Me.SecondField = MySecondField
-
Me.ThirdField = MyThirdField
-
-
End Sub
You can modify it to check for Null values before copying, if you desire.
Linq ;0)>
Linq:
So would I have to define the variables like the following: -
MyFirstField = Me.LOB
-
MySecondField = Me.UW
-
MyThirdField = Me.Policy_Type
-
etc......
This is not actually doing a Copy & Paste, but is assigning the fields to variables, going to a new record, then assigning the value of the variables back to the appropriate fields in the new record, so the fields don't have to be hilighted.
The arrow on the left indicates that particular record is the current record, and the sample code will then copy whichever fields of that record you've assigned it in the code. You simply need to replace Me.FirstField, Me.SecondField, etc. with the actual names for the textboxes you wish to copy.
Linq ;0)>
Sorry, we cross posted! Yes, you need to assign the variables just like it did in Post # 4. If you need more than the example showed, just make up more variable names, like MyFourthField, MyFifthField.
Linq ;0)>
Thanks, I have a meeting now but I will try that solution and get back to you on my result.
Thanks a lot...
Keith
Linq:
Finally got a chance to apply your idea. It worked perfectly! Below is the final solution: -
-
Private Sub cmdCopyPasteRec_Click()
-
-
'When the user click on the command button it will copy and paste the highlighted record
-
-
'Confirm that the user wants to copy the record.
-
If MsgBox("You are about to copy the highlighted record," & _
-
" Click the ok button to proceed, if not hit cancel", vbOKCancel, vbDefaultButton2) = vbOK Then
-
-
'If yes, assign field values to be carried forward to variables
-
-
MyField_1 = Me.Policy_Type
-
MyField_2 = Me.Effective_Date
-
MyField_3 = Me.Expiration_Date
-
MyField_4 = Me.Policy_Number
-
MyField_5 = Me.Insured_Name
-
MyField_6 = Me.UW
-
MyField_7 = Me.Broker
-
MyField_8 = Me.LOB
-
MyField_9 = Me.JtnLocationsID
-
MyField_10 = Me.YearID
-
MyField_11 = Me.MonthID
-
-
'Go to a new record
-
DoCmd.GoToRecord , , acNewRec
-
-
'Plug in old values from variables to new record
-
-
Me.Policy_Type = MyField_1
-
Me.Effective_Date = MyField_2
-
Me.Expiration_Date = MyField_3
-
Me.Policy_Number = MyField_4
-
Me.Insured_Name = MyField_5
-
Me.UW = MyField_6
-
Me.Broker = MyField_7
-
Me.LOB = MyField_8
-
Me.JtnLocationsID = MyField_9
-
Me.YearID = MyField_10
-
Me.MonthID = MyField_11
-
-
End If
-
End Sub
-
-
Once again thanks a lot.
I also thought it would be nice if I could get the entire row that is selected to highlight. I put another post out there but no response so far. I saw that I could go to the properties of a field and set the backcolor using the get focus event. That works it highlights the entire column of that field if there are multiple rows displayed. Is there a way to get just the entire row to highlight (the one that is displaying the arrow). I am thinking that this visual is better for the end user rather than the default arrow that displays and I could have an error check to make sure that a row has been selected
Thanks,
Keith.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Kevin Schneider |
last post by:
Please forgive me if this is a bit off topic, but I haven't had any
takers in other forums.
With ASP.NET projects, is it possible to have VS.NET automatically
change the configuration options of the "Copy Project" dialog box
based on the value selected in the "Solution Configurations" drop down
list?
I'd like to set up the project that when Release is selected and I
select "Copy Project", my production server's values are filled in.
|
by: Tom Clement |
last post by:
Hi folks. I have a question about "Copy Local". We have quite a few
projects in our solution (35) and some of them reference the very large
"Microsoft.mshtml.dll". I was wondering why leave "Copy Local" set to true
in these projects for that reference and other non-project non-framework
DLLs. It seems to me that if they all reference it from the same location,
then the only project that needs to have "Copy Local" set to true is the...
|
by: interuser |
last post by:
I want to automate deployment that I now do using the "copy project"
button.
Is there a script that does this or ideas how to make one?
I do not want to make a deployment project or use xcopy , so please do
not suggest these:)
|
by: tom777 |
last post by:
For some ASP.NET projects, after I have been working on them awhile the "Copy Project..." stops working when I try to copy the project to the web server, which is on another machine. The error message is
Documents in this folder are not available. The folder may have been moved or deleted, or network problems may be preventing a connection to the server
I looked at Microsoft Knowledge Base Article 828897, and that did not seem to apply...
|
by: Don Wash |
last post by:
Hi There!
I'm using "Copy Project" function of VS.NET to upload my ASP.NET application
to my web server (not my own web server) and they have Front Page Server
Extensions installed as well. However, when I run the "Copy Project"
function, I get this error....
Anybody can help me figure out the problem please?
| |
by: Knepper, Michelle |
last post by:
Hi out there,
I'm a first-time user of the "Copy ... From..." command, and I'm trying
to load a table from a text flat file.
http://www.postgresql.org/docs/7.4/static/sql-copy.html
I don't know if I'm using the command correctly.
Question: I run this command as a superuser, and the "copy from"
command is run like a SQL command on the command line, correct?
|
by: Knepper, Michelle |
last post by:
Hi,
I'm a first-time user of the "Copy ... From..." command, and I'm trying
to load a table from a text flat file.
http://www.postgresql.org/docs/7.4/static/sql-copy.html
I'm getting the following error. Any help will be appreciated. Thank
you.
|
by: ammie65 |
last post by:
I have been trying to create a purchase order database in Access, and I have been successful in creating all the tables, queries and reports that I need. I have only one issue: I need to copy the PO - which has a relationship set up as one-to-many with a subform that includes the PO items (Qty, Desc & Price). I want to be able to create a duplicate record using a simple command button, that not only duplicates the main record, but includes all...
|
by: |
last post by:
Using VS.NET I am wondering what methods developers use to deploy ASP.NET
website content to a remote server, either using FTP or network file copy.
Ideally there would be a one-button or one-key-chord way to upload a single
file or a single site.
In Dreamweaver, you can hit "Control-Shift-U" to upload a single file to the
remote site you have configured. This is extremely handy when you're doing
quickie fixes and development, more...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |