473,386 Members | 1,606 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Query to retrieve RefNumber from current record NOT last saved record

ollyb303
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 1782
Rabbit
12,516 Expert Mod 8TB
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
Thanks Rabbit,

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

Cheers,

Olly
Jan 16 '08 #3
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 Expert Mod 8TB
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
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...
2
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...
0
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...
2
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:...
8
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,...
1
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...
12
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...
1
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...
7
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
Oralloy
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,...
0
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...

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.