Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old June 19th, 2005, 05:33 PM
Friend of Wrox
Join Date: Mar 2005
Posts: 264
Thanks: 0
Thanked 0 Times in 0 Posts
Default Error trying to search for value in unbounded form

Hi guys. I made a unbounded form that has option to search for customerno .
 Whenever I try type a customerno and click on the search button I get the following error.
I be happy if some expert help fix this error. Thanks


Run -time error '2109':

There is no field named 'customerno' in the current record

=====>searcherror pic of the form

Option Compare Database
Option Explicit

Sub clearTextBoxes()
''clearing the tow texboxes txtCompanyName and txtCustomerId
Me.customerNumber.Value = ""
Me.customerName.Value = ""
End Sub
Sub getReadyForAnAddOperation()

Me.cmdSave__.Enabled = True
Me.cmdCancel.Enabled = True

Me.cmdAdd__.Enabled = False
Me.cmdEdit.Enabled = False
Me.cmdDelete.Enabled = False

End Sub

Sub stateOnLoad()

Me.cmdCancel.Enabled = True
Me.cmdSave__.Enabled = False
Me.cmdEdit.Enabled = True
Me.cmdAdd__.Enabled = True

'''disableing the cancel and save button on load

'''Me.cmdCancel.Enabled = False
'''Me.cmdSave__.Enabled = False

End Sub

'declaring subrotine
Sub FillFeilds()

Me.customerNumber = myRS.Fields("customerno")
Me.customerName = myRS.Fields("customername")

End Sub

Private Sub cmdAdd___Click()
pbAddingARecord = True
'''changing the value of this boolean variable


End Sub

Private Sub cmdCancel_Click()
End Sub

Private Sub cmdDelete_Click()

Dim x As Variant

x = MsgBox(" You are abut to delete " & Me.customerName & " from this table - proceed ? ", vbOKCancel)

If x = 1 Then

With myRS


End With

End If

End Sub

Private Sub cmdEdit_Click()
pbEditingARecord = True
'''changing the value of this boolean variable

End Sub

Private Sub cmdMoveFirst_Click()
End Sub

Private Sub cmdMoveLast_Click()
End Sub

Private Sub cmdMoveNext_Click()

If pbAddingARecord = True Or pbEditingARecord = True Then
MsgBox ("Please  save or cancel changes first ")
Exit Sub
End If
If myRS.EOF Then

MsgBox ("Last Record")

End If

End Sub

Private Sub cmdMovePreviouse_Click()

If myRS.BOF Then
MsgBox (" First record")

End If

End Sub

Private Sub cmdSave___Click()
If pbAddingARecord = True Then


End If

If pbEditingARecord = True Then


End If

'''inserting the value of textboxes to the table fields.feeding the date to record set

myRS.Fields("customerno").Value = Me.customerNumber.Value
myRS.Fields("customername").Value = Me.customerName.Value

'''calling update method. it comittes the changes

pbAddingARecord = False
pbEditingARecord = False
End Sub

Private Sub cmdSearch_Click()
    Dim strStudentRef As String
    Dim strSearch As String

'Check txtSearch for Null value or Nill Entry first.

    If IsNull(Me![txtSearch]) Or (Me![txtSearch]) = "" Then
        MsgBox "Please enter a value!", vbOKOnly, "Invalid Search Criterion!"
    Exit Sub
End If

'Performs the search using value entered into txtSearch
'and evaluates this against values in customerno

    DoCmd.GoToControl ("customerno")
    DoCmd.FindRecord Me!txtSearch


    strStudentRef = customerNumber.Text
    strSearch = txtSearch.Text

'If matching record found sets focus in customerNumber and shows msgbox
'and clears search control

    If strStudentRef = strSearch Then
        MsgBox "Match Found For: " & strSearch, , "Congratulations!"
        txtSearch = ""

    'If value not found sets focus back to txtSearch and shows msgbox
            MsgBox "Match Not Found For: " & strSearch & " - Please Try Again.", _
            , "Invalid Search Criterion!"
    End If
End Sub

Private Sub Form_Load()

Set db = CurrentDb()

'''Set myRS = db.OpenRecordset("select * from customer")

Set myRS = db.OpenRecordset("customer", dbOpenTable)

''' need to learn how to add index to customer table

'''myRS.Index = ("Company Name")

'calling subroutine

End Sub

Private Sub lblFindIt_Click()

With myRS

Select Case Me.lblFindIt.Caption

Case "Company Name"

Me.lblFindIt.Caption = " First Name "

''' this indexcontactfirstname should already exist in the table
''' you can also create index trough code on tables. this method
''' not good in multi user evironment . best way to create indexes and
''' refere them trough code
.Index = "CotactFirstName"

Case "First Name"

Me.lblFindIt.Caption = " Last Name "

.Index = "CotactLastName"

Case "Last Name "
Me.lblFindIt.Caption = "Company Name "
.Index = "CompanyName"

End Select
End With


End Sub

Private Sub textFindIt_Change()

Dim strSeek As Variant
Dim posInmyRS As Variant
''' feeding it the value from text box
strSeek = Me![textFindIt].Text

With myRS

posInmyRS = myRS.Bookmark

.Seek ">=", strSeek

If .NoMatch = True Then

myRS.Bookmark = posInmyRS

Exit Sub

End If

 End With
End Sub

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to add attribute to unbounded element 2BOrNot2B XML 4 January 16th, 2007 03:42 PM
Problem transforming unbounded types. amac XSLT 3 July 8th, 2006 04:18 AM
passing a value to a field in a unbounded form chacquard Access VBA 3 September 7th, 2005 07:25 AM
How to add search functionality to unbounded form? method Access VBA 4 June 24th, 2005 06:40 AM
Unbounded fields cjordan Crystal Reports 1 January 1st, 2004 01:41 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.