473,624 Members | 2,122 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Query to retrieve RefNumber from current record NOT last saved record

ollyb303
74 New Member
Hi,

I have a problem I need some help with.

In my Access 2000 database (used for logging complaints to my company), I'm using the following code to send an email to our finance dept when a refund is requested:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Save_Record_Click()
  2. On Error GoTo Err_Save_Record_Click
  3.  
  4. Dim strTo As String
  5. Dim strCC As String
  6. Dim strSubject As String
  7. Dim strBody As String
  8. Dim FirstFile As String
  9.  
  10.  
  11.     If RefundStatus = "sent" Then
  12.         MsgBox "THIS REFUND HAS ALREADY BEEN SENT - LOG NOT SAVED"
  13.         Exit Sub
  14.     Else
  15.         End If
  16.  
  17.     If Confirmation = -1 Then
  18.         strCC = "email@provider.com"
  19.     Else:
  20.         strCC = ""
  21.     End If
  22.         strTo = "email2@provider.com"
  23.         strSubject = "Refund"
  24.         strBody = "Refund for authorisation"
  25.         FirstFile = "h:\financereport.rtf"
  26.  
  27.         DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
  28.  
  29.  
  30.  
  31.     If Refund_Amount > 0 Then
  32.  
  33.         If fIsAppRunning = False Then
  34.             MsgBox "PLEASE LOG ON TO LOTUS NOTES BEFORE TRYING TO SEND REFUND REQUEST" & Chr$(10) & "                                              *REFUND NOT SENT*"
  35.             Exit Sub
  36.         Else
  37.         End If
  38.  
  39.  
  40.         DoCmd.OutputTo acOutputReport, "FinanceReport", acFormatRTF, "H:\financereport.rtf"
  41.  
  42.         SendNotesMail strTo, strCC, strSubject, strBody, FirstFile
  43.         RefundStatus.SetFocus
  44.         RefundStatus.Text = "sent"
  45.         DoCmd.GoToRecord , , acNext
  46.         MsgBox "REFUND REQUEST HAS BEEN SENT TO FINANCE" & Chr$(10) & "              * LOG SAVED, THANK YOU *"
The finance report is created using a query where the details are retrieved using "MaxOfRefNumber " where RefNumber is an autonumber. This is causing problems when a second user starts logging a complaint after the first user, but saves before the first does, or when a user starts logging a complaint, partially completes the form, then has to log a second call and go back the original record. In these cases the details from the wrong record are being retrieved for the finance report.

Crunch time: Is there a way I can retrieve the details for the CURRENT record, rather than the record with the highest reference number?

Any help gratefully received.

Many thanks,

Olly
Jan 15 '08 #1
4 1798
Rabbit
12,516 Recognized Expert Moderator MVP
Rather than using the max reference number, have the query/report use the current reference number from your form. It can be called using the format Forms!FormName! ControlName
Jan 15 '08 #2
ollyb303
74 New Member
Thanks Rabbit,

Where do I do this? I'm not used to referencing forms in queries/reports.

Cheers,

Olly
Jan 16 '08 #3
ollyb303
74 New Member
In fact, don't worry I have worked out myself that I can create a new report and use this syntax directly on the report (which makes my query redundant!)

Thanks for your help rabbit, much appreciated!
Jan 16 '08 #4
Rabbit
12,516 Recognized Expert Moderator MVP
Not a problem, good luck.
Jan 16 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
6543
by: Paul Wagstaff | last post by:
Hi there I have 2 tables: tblAccuracy & tblClearance Users add new records to tblAccuracy using frmRegister. Under specific conditions I need to append the current record from frmRegister into tblClearance. I was thinking of placing the code on the form's BeforeUpdate event so that it will fire whether the user closes the form or attempts to create another record.
2
2536
by: Willem | last post by:
Hi there, I'm sort of new with doing much record manipulation with queries. Up till now I've been programming VBA and doing record looping to get my results. This works fine but tends to get very, very slow as the number of records grows - somewhere in the number of 5,000,000. I imagine queries are much faster but am not quite sure if queries will do the trick. My problem:
0
1726
by: JC Voon | last post by:
Hi All: I'm new in Threading and Web Services, can someone please verify my code, i'm not sure whether this is the correct way, althought it is partially work, but some time it will raise exception at FillDatatable dr.AcceptChanges, and also the XTraGridControl will not response when click on the column header to do sorting and filtering. What i'm trying to do is very simple, i just want to retrieve a very large table from web service...
2
3380
by: Wade | last post by:
I am pretty new to Access, especially writing code, but I found code on the web to do just what I want and it is posted below. It returns a field value from a previous record. I found the code at: http://support.microsoft.com/?kbid=210504; many of you have probably seen this code. I have an Access form and a query, both based on exactly the same table, a simple two field table with an ID field and a field of consecutive numbers in consecutive...
8
10780
by: kepston | last post by:
I have a situation where I need to record scrap quantities for parts that we sell and parts that are supplied, in a single table. I have a UNION query that combines the part numbers successfully, allowing the user to select from a combo box without knowing whether the part is supplied or manufactured. I need to provide a DEFAULT value for cost (which, if changed later would not be wrong). To do this, I would like to pull the price from the...
1
1974
by: Andy_Khosravi | last post by:
Background: Access 2003 (converted from A97 DB recently), database is split into FE/BE with the FE residing on client machine. I've got a question about how I can possibly optimize a query I've built. This may seem relatively straight forward to some of you more experienced programmers, but I'm almost entirely self-taught. This means that I have some gaps in my knowledge and sometimes go about doing things the hard way never knowing...
12
2438
by: Michel Esber | last post by:
Hello, Db2 Linux LUW FP 15. Consider table A (ID varchar, EXECUTION_DATE date). a) I want to first retrieve all IDs that have not executed during the last 90 days: select distinct ID from table_B where NOT EXISTS
1
2173
by: jmarcrum | last post by:
Hey everyone, I have a question that's been troubling me for a bit. I work for Alabama Power. I have 1 table (tblOutages). Every morning I import a list of Power Outages for the state of Alabama into that table. I have a yes/no (chkOutage) field set-up in the table to set chkOutage = TRUE on every record that is imported. Here's my question, and it's a bit long. :) I would be much appreciative if anyone could help! At the end...
7
10264
by: shalskedar | last post by:
In a query i want to retrieve the value in such a way that if the value for the current record for a given column is 0 then it should go to the next record & take the value. for ex-I 've column Payment received in the query.I want to retrieve the value in such a way that if the current record value for this column is 0 then it should go to the next record value..
0
8236
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8173
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,...
0
8621
jinu1996
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...
1
8335
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7159
agi2029
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...
0
5563
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();...
0
4079
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...
1
1785
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1482
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.