Access_guy49
Registered User.
- Local time
- Today, 00:49
- Joined
- Sep 7, 2007
- Messages
- 462
OK so I have a very strange bug.
I am using Access 2003. on an XP machine with SP3 installed.
I have a split database, the front end has a form for inputing new records.
The user of the form has asked for a button to duplicate some of the information on the form for people where he is creating more than one file.
E.g - our planner fills in a record for John Smith. Then he clicks the duplicate button to create Another blank record for John Smith. Our planner wanted the button to bring over the basic information that would be the same for both records and only leave blank the fields that would be different.
I did this by storing the values of the desired fields in an array. Then using the GoToRecord,,AcNewRec command, i create a new record and then populate the fields with the values in the array. Not terribly complicated.
the problem is that every time it gets to the new record line of code, I get an error. "2105 - can't go to specified record"
YET...
If i place a stop, one line before the AcNewRec, and then step through the code, everything works perfect.
Also if i just use a standard wizard "next record" or "New Record" button. they both work just fine.
I can't understand how when you step through, it works, and when you just run it outright, it doesn't.
PLEASE PLEASE Help.
I am using Access 2003. on an XP machine with SP3 installed.
I have a split database, the front end has a form for inputing new records.
The user of the form has asked for a button to duplicate some of the information on the form for people where he is creating more than one file.
E.g - our planner fills in a record for John Smith. Then he clicks the duplicate button to create Another blank record for John Smith. Our planner wanted the button to bring over the basic information that would be the same for both records and only leave blank the fields that would be different.
I did this by storing the values of the desired fields in an array. Then using the GoToRecord,,AcNewRec command, i create a new record and then populate the fields with the values in the array. Not terribly complicated.
the problem is that every time it gets to the new record line of code, I get an error. "2105 - can't go to specified record"
YET...
If i place a stop, one line before the AcNewRec, and then step through the code, everything works perfect.
Also if i just use a standard wizard "next record" or "New Record" button. they both work just fine.
I can't understand how when you step through, it works, and when you just run it outright, it doesn't.
PLEASE PLEASE Help.
Code:
'This button duplicates the values in many fields for a new record.
Dim MyValues(17) As String
Me.Combo117.SetFocus
MyValues(0) = Me.Combo117
Me.Combo119.SetFocus
MyValues(1) = Me.Combo119
Me.Combo121.SetFocus
MyValues(2) = Me.Combo121
MyValues(3) = Me.LotPlan
MyValues(4) = Me.PlanNum
MyValues(5) = Me.F_Name
MyValues(6) = Me.L_Name
MyValues(7) = Me.HomePhone
MyValues(8) = Me.Postal
MyValues(9) = Me.Business_Phone
MyValues(10) = Me.Business
MyValues(11) = Me.Munic
MyValues(12) = Me.Lot
MyValues(13) = Me.Conc
MyValues(14) = Me.Street_Num
MyValues(15) = Me.Street
MyValues(16) = Me.Easting
MyValues(17) = Me.Northing
'Tried saving record first, didn't solve problem.
'I useually uncomment this line and place my stop hear in order to step through the code to have it work.
'DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
'Also tried using a simple wait function just to see if that helped. didn't.
' WaitTime (3)
' DoEvents
DoCmd.GoToRecord , , acNewRec
'Tried AcNext and got the same result.
'DoCmd.GoToRecord , , acNext
'This part works fine, but i can't only get to it by stepping through the above lines.
Me.Combo117 = MyValues(0)
Me.Combo119 = MyValues(1)
Me.Combo121 = MyValues(2)
Me.LotPlan = MyValues(3)
Me.PlanNum = MyValues(4)
Me.F_Name = MyValues(5)
Me.L_Name = MyValues(6)
Me.HomePhone = MyValues(7)
Me.Postal = MyValues(8)
Me.Business_Phone = MyValues(9)
Me.Business = MyValues(10)
Me.Munic = MyValues(11)
Me.Lot = MyValues(12)
Me.Conc = MyValues(13)
Me.Street_Num = MyValues(14)
Me.Street = MyValues(15)
Me.Easting = MyValues(16)
Me.Northing = MyValues(17)