Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code working in debug not runtime

Status
Not open for further replies.

corner40

Technical User
Nov 20, 2002
126
CA
I have some code that when I step through it, it works as expected, but when i an just using the ap without stepping into the code it doesn't work as it should. Has anyone encountered this before...here is the code just to help any that I can.
all suggestions are greatly appreciated.
visitdate = Forms![f_bookinghead]![f_BookingHeadForm].Form![BookingDate]

If IsNull(DLookup("bookingdetailid", "bookingdetail", "[bookingheadid] = " & Me.BookingHeadID & " AND [kid] = " & Me.lstKidSelect.Column(0))) Then
'MsgBox "is null"
If Forms![f_bookinghead]![f_BookingHeadForm]![f_BookingDetail].Form![BookingDetailID] > 1 Then
Forms![f_bookinghead]![f_BookingHeadForm]![f_BookingDetail].SetFocus
DoCmd.GoToRecord , , acNewRec
End If

Forms![f_bookinghead]![f_BookingHeadForm]![f_BookingDetail].Form![KID] = Me.lstKidSelect.Column(0)
bday = Me.lstKidSelect.Column(4)
Forms![f_bookinghead]![f_BookingHeadForm]![f_BookingDetail].Form![lblAge].Caption = Int(DateDiff("d", bday, visitdate) / 365)
Forms![f_bookinghead]![f_BookingHeadForm]![f_BookingDetail].Form![SignInID] = Forms![f_login].SignInID

Forms![f_bookinghead]![f_BookingHeadForm]![f_BookingDetail].Enabled = True
Forms![f_bookinghead]![f_BookingHeadForm]![f_BookingDetail].Form!BookingHeadID = Me.BookingHeadID
Forms![f_bookinghead]![f_BookingHeadForm]![f_BookingDetail].Form!cboSkiType.SetFocus
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
'BookingLstRefresh
Else
bdID = DLookup("bookingdetailid", "bookingdetail", "[bookingheadid] = " & Me.BookingHeadID & " AND [kid] = " & Me.lstKidSelect.Column(0))
Forms![f_bookinghead]![f_BookingHeadForm]![f_BookingDetail].Form!cboSkiType.SetFocus
Me.Filter = bdID
Me.FilterOn = True
End If


the problem that is occuring is this...
when I am running the program normally the subform f_bookingheadform goes to a new record(wrong). When I step through the code, the sub-subform f_bookingdetail goes to a new record(correct). It's as if when the code is being run normally the setfocus event doesn't have time to set the focus.
Again, any suggestions would be greatly appreciated.
thank
Jeremy
 
Have you tried sticking in a DoEvents right after that?

If that doesn't work, try calling the code in thread181-762985.

---
Jeremy Wallace
METRIX Project Coordinator
Fund for the City of New York
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top