Hi:
I'm running into an overflow problem with the following code (with the variable nCNOS), but get a compile error (AddInvoice rsInvoice, nRNOS, nCNOS) if I change it to Long. Can someone help? -
Dim stDocName As String
-
Dim nRetreatNumber As Integer
-
Dim nRNOS As Integer
-
'Dim nCNOS As Integer
-
Dim nCNOS As Long
-
-
'check whether there is a customer number
-
nRNOS = Forms!frmSpecialEventsEnterDeleteModify.RNOS
-
nCNOS = Forms!frmSpecialEventsEnterDeleteModify.Text191
-
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
-
-
If IsNull(nCNOS) Or nCNOS = 0 Then
-
Msg = "You must select a person to bill before you can create an invoice"
-
Style = vbOK + vbCritical
-
Title = "Select a person to bill"
-
MsgBox Msg, Style, Title
-
Exit Sub
-
End If
-
-
Dim sWhere As String
-
Dim rsInvoice As ADODB.Recordset
-
Dim rsCount As ADODB.Recordset
-
-
nRNOS = Forms!frmSpecialEventsEnterDeleteModify.[RNOS]
-
Set rsCount = New ADODB.Recordset
-
Set rsInvoice = New ADODB.Recordset
-
sWhere = "SELECT * FROM tblInvoice WHERE RNOS = " & nRNOS & ""
-
rsCount.Open sWhere, CurrentProject.Connection, adOpenDynamic, adLockOptimistic
-
-
'check if an invoice already exists for this event
-
If rsCount.EOF Then
-
rsInvoice.Open "tblInvoice", CurrentProject.Connection, adOpenDynamic, adLockOptimistic
-
AddInvoice rsInvoice, nRNOS, nCNOS
-
rsInvoice.Close
-
stDocName = "rptInvoiceForSpecialEvents"
-
DoCmd.OpenReport stDocName, acPreview
-
Else
-
stDocName = "rptInvoiceForSpecialEvents"
-
DoCmd.OpenReport stDocName, acViewPreview
-
End If
4 2332
Hi. You don't show your code for AddInvoice, so I am just guessing here - is the second parameter for AddInvoice defined as an integer? If it is, passing a Long when an Integer type is expected will cause an error. You would need to change the Integer definition in AddInvoice to Long for compatibility.
Otherwise, there is no obvious problem with the code posted.
-Stewart
Assigning text to a number field:
nCNOS = Forms!frmSpecialEventsEnterDeleteModify.Text191
looks odd.
You could use Val() like:
nCNOS = val(Forms!frmSpecialEventsEnterDeleteModify.Text19 1 )
to turn the textfield into a (long) number, but I would probably keep the field having the same datatype as in the original table.
An alternative I often use is to have a combobox holding a DISTINCT value for the personID so the user can only select existing values...
Nic;o)
@Stewart Ross Inverness
Thanks Stewart! How blind am I? Of course, when I look at the AddInvoice code, CNOS it is defined as an Integer....
All works well now.
Thanks!
@nico5038
Thanks! I'll try your suggestion...
Thanks for the quick reply.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Trevor Best |
last post by:
I did a test once using a looping variable, first dimmed as Integer,
then as Long. I found the Integer was quicker at looping. I knew this to
be true back in the 16 bit days where the CPU's (80286)...
|
by: Peter Ammon |
last post by:
When I add an unsigned long long and an int, what type do each of the
values get promoted to before the addition is performed? What is the
type of the resulting expression? What occurs if the...
|
by: Mike Miller |
last post by:
What is the best way to convert a managed unsigned int64 to an
unsigned long? Basically I need to do the following:
System::UInt64 managedInt = 10;
unsigned long unmanagedInt;
unmanagedInt =...
|
by: rsine |
last post by:
I have developed a program that sends a command through the serial port
to our business system and then reads from the buffer looking for a
number. Everything worked great on my WinXP system, but...
|
by: Jon Lapham |
last post by:
I have a table that stores TEXT information. I need query this table to
find *exact* matches to the TEXT... no regular expressions, no LIKE
queries, etc. The TEXT could be from 1 to 10000+...
|
by: Yevgen Muntyan |
last post by:
Hey,
I was reading C99 Rationale, and it has the following two QUIET CHANGE
paragraphs:
6.5.3.4: "With the introduction of the long long and extended integer
types, the sizeof operator may...
|
by: Paulo Matos |
last post by:
Hello,
Is it safe to assume a size_t is an unsigned long? (is it forced by
the standard?)
Thank you,
Paulo Matos
|
by: Tim |
last post by:
Hello All, I could use some help on an error that is just now popping it's
head up.
Seems that the autoincrement numeric has hit 32,767. The autoincrement is
used in various locations in the...
|
by: snorble |
last post by:
I started creating a simple "bits" class, intended to act like a array
of bits. This was my initial idea, basically just overriding the
string representation to display the bitmask (so far):
...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
| |