Hi!
As you can see I have worked with my code and done some changes. Now
the code will execute, because of this, and because I took away some
code in the OnCurrent event that was probably causing a clash. It does
in fact copy the new Invoice number and the data from tblOrderDetails ,
but still missing is the CustID-field, that it refuses to copy. The
CustID-field is a Combobox on frmOrders, and is by no way locked or...
I again have double-checked the name and field-properties, so as to
avoid naming confuses and so on...All fields in forms now has the same
names as underlying tables.
Dim rs As DAO.Recordset
Dim sqlNew As String
Dim lngNewOrderID As Long
Dim MyMsg As String, MyTtl As String
Dim MyBtn As Integer, RetVal As Integer
MyMsg = "You are about to copy this invoice." & Chr(13)
MyMsg = MyMsg & "All data will be copied to new Invoice," & Chr(13)
MyMsg = MyMsg & "and have a new invoice number." & Chr(13)
MyMsg = MyMsg & Chr(13)
MyMsg = MyMsg & "Sure you will continue?"
MyBtn = 292 'A "YES/NO" button and "NO"button is default
MyTtl = "COPY INVOICE?"
RetVal = MsgBox(MyMsg, MyBtn, MyTtl)
Select Case RetVal
Case 7
DoCmd.CancelEve nt
Me!lblInfo.Capt ion = "COPY ABORTED!"
Case 6
Me.Refresh
Set rs = Me.RecordsetClo ne
With rs
.AddNew
!CustID = Me!CustID 'It will not copy this field.
!MyDate = Now 'Date is being set ok
!MyTime = Time 'Time is being set ok
.Update
End With
rs.Bookmark = rs.LastModified
lngNewOrderID = rs!InvoiceID
sqlNew = "INSERT INTO
tblOrderDetails (ItemID,Amount, Discount,Price, Fee,InvoiceID) " & _
"SELECT ItemID,Amount,D iscount,Price,F ee," & lngNewOrderID & _
" FROM tblOrderDetails " & _
"WHERE InvoiceID = " & Me!InvoiceID
'I'm happy because the sqlNew is being copied
CurrentDb.Execu te sqlNew, dbFailOnError
End Select
I'm not sure if there is a difference from win98 to win 2000/win XP,
but I remember that this calculation (under win98):
=Sum(Nz(([Price]*[Amount]*(1-[Discount])/100)*100))
had to be changed (under win 2000/win XP) to:
=Sum(Nz([Price]*[Amount]*[Discount]))
in order to work properly. I don't know why. Do You?
However, I'll keep on working! :-) 1 1757 ge***********@h otmail.com (Geir Baardsen) wrote: !CustID = Me!CustID 'It will not copy this field.
Just a thought, but have you tried naming your control something other than
the field name (eg "cboCustID" )? Having the names the same may be the
cause of some confusion.
!CustID = Me!cboCustID
Regards,
Keith. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Tlm |
last post by:
Hello All,
I have a form (FrmA) with a subform (SubFrmB) embedded in it. SubFrmB also
has a subform embedded in it (SubFrmC) The form's recordsource is based on a
table (TblA). SubFrmB's recordsource is also based on a table (TblB).
SubFrmC's recordsource is also based on a table (TblC).
There is a one-to-many relationship between TblA (one) and TblB (many).
|
by: Sean Howard |
last post by:
Dear All,
As is my want I need to do something in Access that seems simple but
cannot fathom out.
I have main form with two subforms, both datasheets with an almost
identical table structure.
I want to add the functionality to copy records from subformA to
subformB WITHOUT USING COPY/PASTE. The reasonfor this is that I must
|
by: Geir Baardsen |
last post by:
Hi!
This is a routine for copying a recordset into a new order.
It has worked fine under Win98. However, my client has changed to
Win XP, and suddenly it doesn't work anymore. I keep getting the
following error message: Object is not in collection.
So I do a very thorough check and doublecheck of fieldnames from underlying
table, tblOrderDetails. I even write them down in NotePad, and compares them...
but there is no difference. I even...
|
by: JumpinJeff |
last post by:
I need to create a copy of a record and *all* it's related data, from
*all* it's related tables. The only exception is one of it's primary
keys will be incremented.
This app is an onging project for me, so I really dread manually
quering every field in every table, because of all my upcoming
changes, and because there are abbout 12 tables. I just want to be
able to say "copy all related data and increment the key".
Any ideas would be...
|
by: Karl Irvin |
last post by:
While adding data to a record set, I use something like
rst! = some variable
rst! = some variable
......
rst! = some variable
The rst! , rst! etc. are manually typed in and it gets
tedious typing a lot of these.
| |
by: Eric |
last post by:
I want to open up 2 record sets. Then, copy everything from one record
set to another (excluding a few fields). Is this possible?
I need to exclude my primary key, and fields starting with "TMP_".
I'm trying this, but it's saying ADODB.Recordset error '800a0c93'
Operation is not allowed in this context.
|
by: Slez via AccessMonster.com |
last post by:
What is my best option for enabling users to copy and paste an entire
recordset, but allowing them to change the value of the "one" record in a
series of one-to-many relationships?
For example:
EstimateID in tblEstimate is on the one side of a relationship with records
in tblItem...
which is on the one side of a relationship with records in tblItemDetail.
What I'd like to enable users to do is (maybe via form?):
|
by: Jim Devenish |
last post by:
I wish to copy a table on a SQL Server backend to a table on an Access
(.mdb) front end in the simplest way.
I have the following to get the recordset but am seeking something
easier.
Dim theConnectionString
theConnectionString = "Driver=SQL Server;
Server=Server;Database=myData;Trusted_Connection=Yes"
|
by: Richnep |
last post by:
Hi all,
I have tabbed subforms where I need to copy one field value from one
subform over to another subform. Although I can run an update query to
accomplish this I would like to do it through VBA.
sub tables relationships are 1:N with the main table.
So the recods display like this in the subform:
|
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: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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: 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...
| |