Here is My code for starters: - Select Case varMonth
-
Case Is = 1
-
varLongMonth = "January"
-
Case Is = 2
-
varLongMonth = "Feburary"
-
Case Is = 3
-
varLongMonth = "March"
-
Case Is = 4
-
varLongMonth = "April"
-
Case Is = 5
-
varLongMonth = "May"
-
Case Is = 6
-
varLongMonth = "June"
-
Case Is = 7
-
varLongMonth = "July"
-
Case Is = 8
-
varLongMonth = "August"
-
Case Is = 9
-
varLongMonth = "September"
-
Case Is = 10
-
varLongMonth = "October"
-
Case Is = 11
-
varLongMonth = "November"
-
Case Else
-
varLongMonth = "December"
-
End Select
-
txttest = varLongMonth
-
-
Dim db As DAO.Database
-
Dim rs1 As DAO.Recordset
-
-
Set db = CurrentDb()
-
Set rs1 = db.OpenRecordset("Query_2")
-
rs1.MoveFirst
-
-
Do Until rs1.EOF
-
If rs1![ID] = Val(ID) Then
-
NumOrdTotal = rs1!varLongMonth + Val(NumOrd)
-
rs1.Edit
-
rs1!varLongMonth = NumOrdTotal
-
rs1.Update
-
End If
-
rs1.MoveNext
-
Loop
-
-
rs1.Close
-
Set rs1 = Nothing
-
Set db = Nothing
-
At the line, NumOrdTotal = rs1!varLongMonth + Val(NumOrd) , I get an error saying: Item not found in Collection.
I believe I am getting this error because where the field belongs at rs1!"fieldName" I have a variable. I need to be able to use this variable to identify the field depending on certain criteria. How can I use this variable to do that?
7 2136 NeoPa 32,556
Expert Mod 16PB NeoPa 32,556
Expert Mod 16PB
Try using this to convert month number to string : - varLongMonth = Format(CDate("25/" & varMonth & "/1999"),"mmmm")
Try :
Thanks NeoPa that did the trick, but now I got another probelm, WOOHOO. I can not get it to enter data into other records, just the first record. It is not giving any errors it runs it like its working. So its just some little thing.
Updated Code: - Select Case varMonth
-
Case Is = 1
-
varLongMonth = "January"
-
Case Is = 2
-
varLongMonth = "Feburary"
-
Case Is = 3
-
varLongMonth = "March"
-
Case Is = 4
-
varLongMonth = "April"
-
Case Is = 5
-
varLongMonth = "May"
-
Case Is = 6
-
varLongMonth = "June"
-
Case Is = 7
-
varLongMonth = "July"
-
Case Is = 8
-
varLongMonth = "August"
-
Case Is = 9
-
varLongMonth = "September"
-
Case Is = 10
-
varLongMonth = "October"
-
Case Is = 11
-
varLongMonth = "November"
-
Case Else
-
varLongMonth = "December"
-
End Select
-
txttest = varLongMonth
-
'========================================================================================
-
Dim db As DAO.Database
-
Dim rs1 As DAO.Recordset
-
-
Set db = CurrentDb()
-
Set rs1 = db.OpenRecordset("CartUse")
-
rs1.MoveFirst
-
-
Do Until rs1.EOF
-
If rs1.Fields(ID) = Val(ID) Then
-
NumOrdTotal = Val(rs1.Fields(varLongMonth)) + Val(varNumOrd)
-
txttest2 = Val(NumOrdTotal)
-
rs1.Edit
-
rs1.Fields(varLongMonth) = Val(NumOrdTotal)
-
rs1.Update
-
End If
-
rs1.MoveNext
-
Loop
-
-
rs1.Close
-
Set rs1 = Nothing
-
Set db = Nothing
-
NeoPa 32,556
Expert Mod 16PB
You need to post this as a new question as this is unrelated to this one.
Try to explain exactly what you're after a little more clearly though. If I'd understood the question I would have tried to answer it anyway.
NeoPa 32,556
Expert Mod 16PB
Try using this to convert month number to string : - varLongMonth = Format(CDate("25/" & varMonth & "/1999"),"mmmm")
BTW. I'm pleased that helped and thanks for the feedback - always valuable.
Did you notice this post (#3 quoted)? It should help you to get rid of a whole hunk of code.
NeoPa 32,556
Expert Mod 16PB Sign in to post your reply or Sign up for a free account.
Similar topics
by: N. David |
last post by:
In bash, you can include a variable as part of a filename. For
example:
date=$(date)
cat log.txt > $date"_log.txt"
Which, when setting the right options in date, creates a file named...
|
by: Lokkju |
last post by:
I am pretty much lost here - I am trying to create a managed c++
wrapper for this dll, so that I can use it from c#/vb.net, however, it
does not conform to any standard style of coding I have seen....
|
by: tino |
last post by:
Years ago there used to be a feature in dBase and FoxPro
where the content of a variable could be used a variable
name:
Var1 = "Var2"
Var2 = blank
&Var1 = "Hallo"
this way Var2 would get...
|
by: Alex |
last post by:
Given the following code:
Private Sub ButtonShowTheIntValue_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles ButtonShowTheIntValue.Click
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
|
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,...
|
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...
|
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,...
| |