
Signature
Bob Larson
Access MVP
Access World Forums Administrator
Utter Access VIP
Tutorials at http://www.btabdevelopment.com
__________________________________
Thanks Bob Here is my Code, Regards Bob:
Private Sub cmdCreateHoldingInvoices_Click()
'It creates the holding Invoices for selected horses.
Dim recInvoice_ItMdt As ADODB.Recordset
Set recInvoice_ItMdt = New ADODB.Recordset
Dim recHorseInfo As ADODB.Recordset
Set recHorseInfo = New ADODB.Recordset
Dim recTmpInvoice_ItMdt As ADODB.Recordset
Set recTmpInvoice_ItMdt = New ADODB.Recordset
Dim lngIntermediateID As Long
Dim nloop As Long
'To Save the record in alphabetical order.
recInvoice_ItMdt.Open "SELECT * FROM tblInvoice_ItMdt", cnnStableAccount,
adOpenDynamic, adLockOptimistic 'ERROR LINE YELLOW
For nloop = 0 To lstActiveHorses.ListCount - 1
If lstActiveHorses.Selected(nloop) = True Then
Debug.Print lstActiveHorses.Column(1, nloop) 'Prints the Horse Name
Debug.Print lstActiveHorses.Column(0, nloop) 'Prints the Horse Id
recHorseInfo.Open "Select * from tblHorseInfo where HorseID=" _
& lstActiveHorses.Column(0, nloop) & ";", cnnStableAccount,
adOpenDynamic, adLockOptimistic
If recHorseInfo.BOF = False And recHorseInfo.EOF = False Then
With recInvoice_ItMdt
If recInvoice_ItMdt.BOF = False And recInvoice_ItMdt.EOF
= False Then
.MoveLast
lngIntermediateID = Nz(.Fields("IntermediateID"), 0)
+ 1
Else
lngIntermediateID = 1
End If
.AddNew
.Fields("IntermediateID") = lngIntermediateID
.Fields("dtDate") = Format(Now, "dd/mm/yyyy")
.Fields("HorseName") = lstActiveHorses.Column(1, nloop)
.Fields("HorseID") = lstActiveHorses.Column(0, nloop)
.Fields("FatherName") =
Nz(recHorseInfo.Fields("FatherName"), "")
.Fields("MotherName") =
Nz(recHorseInfo.Fields("MotherName"), "")
.Fields("HorseDetailInfo") =
Nz(recHorseInfo.Fields("FatherName"), "") _
& "--" & Nz(recHorseInfo.Fields("MotherName"), "") &
"--" _
&
funCalcAge(Format(Nz(recHorseInfo.Fields("DateOfBirth"), "") _
, "dd-mmm-yyyy"), Format("01-Aug-" & Year(Now()),
"dd-mmm-yyyy"), 1) _
& "-" & Nz(recHorseInfo.Fields("Sex"), "")
.Fields("Sex") = Nz(recHorseInfo.Fields("Sex"), "")
.Fields("DateOfBirth") =
Nz(recHorseInfo.Fields("DateOfBirth"), "")
'Set the default value to GSTOptionText field.
.Fields("GSTOptionsText") = "Plus Tax"
.Fields("GSTOptionsValue") = 0
.Fields("SubTotal") = 0
.Fields("TotalAmount") = 0
Application.SysCmd acSysCmdSetStatus, "Horse Name=" &
.Fields("HorseName")
.Update
.Requery
End With
End If
recHorseInfo.Close
End If
Next
Me.lstActiveHorses.Requery
Application.SysCmd acSysCmdClearStatus
End Sub
> What is the rest of your code, including variable declarations?
>
[quoted text clipped - 37 lines]
>> >> closed or Invalid in this context
>> >> PLEASE HELP!
Bob Vance - 16 Jul 2008 03:12 GMT
Sorry Guys, My fault did not set cnnStableaccount on load form
duuuuuuuuuuuuur Bob
> Thanks Bob Here is my Code, Regards Bob:
> Private Sub cmdCreateHoldingInvoices_Click()
[quoted text clipped - 115 lines]
>>> >> closed or Invalid in this context
>>> >> PLEASE HELP!
boblarson - 16 Jul 2008 06:32 GMT
I see you using
cnnStableAccount
in the code:
recInvoice_ItMdt.Open
But nowhere are you setting the connection (at least not here). How are you
opening the connection?

Signature
Bob Larson
Access MVP
Access World Forums Administrator
Utter Access VIP
Tutorials at http://www.btabdevelopment.com
__________________________________
> Thanks Bob Here is my Code, Regards Bob:
> Private Sub cmdCreateHoldingInvoices_Click()
[quoted text clipped - 114 lines]
> >> >> closed or Invalid in this context
> >> >> PLEASE HELP!
Tom Wickerath - 16 Jul 2008 08:01 GMT
Hi Bob and Bob,
To Bob Vance -
I believe I have an identical copy of your code, from last summer when you
sent me a copy of your database. I will try running it in Access 2007
tomorrow afternoon, and let you know the result. (I only have Access 2007
installed on my laptop PC, which is shut down right now. I'd test it tonight,
but it's already midnight, and I have to start my day tomorrow in about 5
hours). Question for you: Did you run your database in Access 2007 as a .mdb
file, or did you convert it to the new .accdb file format? I'll try to
duplicate exactly what you did.
To Bob Larson -
The answer to your follow-on question, "How are you opening the
connection?", appears to be (from my copy of Bob V's database dated
7/31/2007) as follows:
Option Compare Database
Dim cnnStableAccount As Connection <---Module level variable
Private Sub Form_Load()
Set cnnStableAccount = CurrentProject.Connection
End Sub
Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________
> Thanks Bob Here is my Code, Regards Bob:
<snip>
Bob Vance - 16 Jul 2008 09:09 GMT
Sorry Guys I must have commered out when I was trying to load the new
references
Private Sub Form_Load()
'Set cnnStableAccount = CurrentProject.Connection
End Sub
Anyway took the commer out and now alls GOOD :)
Tom, I did convert it to .accdb but still have a back up in .mdb
A question you might be able to answer if I want to distrubute a version
should I
a) KeyedAccess lock it
b) Put it on a server Front End and Back End
What are your thoughts........Regards Bob
> Hi Bob and Bob,
>
[quoted text clipped - 31 lines]
>
> <snip>
Tom Wickerath - 20 Jul 2008 03:40 GMT
Hi Bob,
> A question you might be able to answer if I want to distrubute a version
> should I
> a) KeyedAccess lock it
> b) Put it on a server Front End and Back End
> What are your thoughts
Sorry, I missed your latest reply earlier....
I don't know what "KeyedAccess" is. Is this some type of commercial add-on?
My thoughts on running a successful multiuser application are pretty much
summed up in this article:
Implementing a Successful Multiuser Access/JET Application
http://www.accessmvp.com/TWickerath/articles/multiuser.htm
If you are talking a Local Area Network (LAN), then I'd use Access MVP Tony
Toews free AutoFE Updater utility:
http://www.granite.ab.ca/access/autofe.htm
Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________
> Sorry Guys I must have commered out when I was trying to load the new
> references
[quoted text clipped - 8 lines]
> b) Put it on a server Front End and Back End
> What are your thoughts........Regards Bob