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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data Access in Form

Status
Not open for further replies.

toccata

Programmer
Jun 26, 2002
65
US
I am opening a form and passing the record key via an argument. However, my seek or findnext routine fails to get the record I wish to retrieve and edit. The argument variable is successfully passed but fails to get the record to update.
 
and how can we help you without any code being posted? Bastien

There are many ways to skin this cat,
but it still tastes like chicken
 
Code of Opened Form Follows:
**********************


Option Compare Database

Private Sub Form_Load()

Dim argPrimekey As String

argPrimekey = Me.OpenArgs

'On Error Resume Next

txtNumber = argPrimekey
HorseNo = txtNumber

GetHorse

Mode = "Edit"
cboHorseName = HorseName
cboHorseName.SetFocus

End Sub

Private Sub GetHorse()

' Find the record that matches the control.

Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[HorseNo] = '" & Me![txtNumber] & "'"
Me.Bookmark = rs.Bookmark

Mode = "Edit"
cboHorseName = rs![HorseName]
cboHorseName.SetFocus

End Sub

Private Sub Build_Descriptions()

On Error Resume Next

HorseShortDescr = ""
HorseLongDescr = ""

HorseShortDescr = LTrim(Str(Year(HorseDOB))) + " " + HorseColor + " " + HorseSex
HorseLongDescr = HorseShortDescr

If HorseSire <> &quot;&quot; Then
HorseLongDescr = HorseLongDescr + &quot;, &quot; + HorseSire
End If

If HorseDam <> &quot;&quot; Then
HorseLongDescr = HorseLongDescr + &quot; - &quot; + HorseDam
End If

If HorseDOB > #1/1/1900# Then
HorseFoalDateDescr = &quot;Foaled &quot; + Str(HorseDOB)
End If

If HorseBirthPlace > &quot;&quot; Then
HorseFoalDateDescr = &quot;Foaled &quot; + Str(HorseDOB) + &quot; in &quot; + HorseBirthPlace
End If

End Sub

Private Sub cboDam_AfterUpdate()

HorseDam = cboDam.Column(1)

End Sub

Private Sub cboDam_Click()

Combo403.SetFocus

End Sub

Private Sub cboSire_AfterUpdate()

HorseSire = cboSire.Column(1)

End Sub

Private Sub cboSire_Click()

cboDam.SetFocus

End Sub

Private Sub cboSortCode_AfterUpdate()

HorseSortDescr = cboSortCode.Column(1)

End Sub

Private Sub chkHorseActive_LostFocus()

Combo178.SetFocus

End Sub

Private Sub Combo165_Click()

cboHorseName = HorseName

End Sub

Private Sub Combo178_AfterUpdate()

HorsePrimeOwner = Combo178.Column(1)
HorseNeck.SetFocus

End Sub

Private Sub Combo182_AfterUpdate()

HorseBoardDesc = Combo182.Column(1)
HorseBoardType = Combo182.Column(2)
HorseBoardRate = Combo182.Column(3)

End Sub

Private Sub Combo235_AfterUpdate()

HorseOwnName1 = Combo235.Column(1)

End Sub

Private Sub Combo237_AfterUpdate()
HorseOwnName2 = Combo237.Column(1)

End Sub

Private Sub Combo239_AfterUpdate()
HorseOwnName3 = Combo239.Column(1)

End Sub

Private Sub Combo239_LostFocus()

If HorseOwn3 = &quot;&quot; Then
cmdAccept2.SetFocus
End If

End Sub

Private Sub Combo241_AfterUpdate()
HorseOwnName4 = Combo241.Column(1)

End Sub

Private Sub Combo243_AfterUpdate()
HorseOwnName5 = Combo243.Column(1)

End Sub

Private Sub Combo245_AfterUpdate()
HorseOwnName6 = Combo245.Column(1)

End Sub

Private Sub Combo287_AfterUpdate()
HorseSortDescr = Combo287.Column(1)
End Sub

Private Sub Combo259_Click()

cboHorseName.SetFocus

End Sub


Private Sub cmdAccept_Click()

Build_Descriptions

HorseNo = txtNumber
HorseName = cboHorseName
DoCmd.GoToRecord , , acFirst
Me.Visible = False

End Sub

Private Sub cmdCancel_Click()

Me.Undo
DoCmd.Close

End Sub

Private Sub Combo259_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst &quot;[HorseNo] = '&quot; & Me![Combo259] & &quot;'&quot;
Me.Bookmark = rs.Bookmark
SetControlsOn
txtNumber = Combo259.Column(0)

End Sub

Private Sub HorseBoardGL_LostFocus()

pgOwners.SetFocus

End Sub

Private Sub HorseChg6_LostFocus()

pgPurchase.SetFocus

End Sub

Private Sub HorseComment_LostFocus()

pgBoard.SetFocus

End Sub

Private Sub HorseDOB_LostFocus()

If HorseDOB >= #1/1/2002# Then
HorseAgeText = &quot;Weanling&quot;
End If

If HorseDOB < #1/1/2002# Then
HorseAgeText = &quot;Yearling&quot;
End If

If HorseDOB < #1/1/2001# Then
HorseAgeText = &quot;Two-yr-old&quot;
End If

If HorseDOB < #1/1/2000# Then
HorseAgeText = &quot;Three-yr-old&quot;
End If

If HorseDOB < #1/1/1999# Then
HorseAgeText = &quot;Four and older&quot;
End If

End Sub

Private Sub HorseInsureValue_LostFocus()

pgSale.SetFocus

End Sub

Private Sub HorseSellPrice_LostFocus()

pgPedigree.SetFocus

End Sub

Private Sub HorseWinnings_LostFocus()

cmdAccept.SetFocus

End Sub

Private Sub cmdPrint1_Click()
On Error GoTo Err_cmdPrint1_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = &quot;frmReportSelectorHorseListing&quot;
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdPrint1_Click:
Exit Sub

Err_cmdPrint1_Click:
MsgBox Err.Description
Resume Exit_cmdPrint1_Click

End Sub

Private Sub cmdMemo_Click()
On Error GoTo Err_cmdMemo_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = &quot;frmHorseMemo&quot;
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdMemo_Click:
Exit Sub

Err_cmdMemo_Click:
MsgBox Err.Description
Resume Exit_cmdMemo_Click

End Sub

Private Sub cmdBreedingEntry_Click()
On Error GoTo Err_cmdBreedingEntry_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = &quot;frmBreeding&quot;
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdBreedingEntry_Click:
Exit Sub

Err_cmdBreedingEntry_Click:
MsgBox Err.Description
Resume Exit_cmdBreedingEntry_Click

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top