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!

confused about displaying a form for a specific record

Status
Not open for further replies.

seducedbycodes

Technical User
Jul 4, 2005
27
AU
Hi,
I want to seach records to display a form relating to a specific quote number. The user will enter the quote number they want in a text box and press a search button which should display the specific quote record on a form.
Any Help would be greatly appreciated
Thanks
 
Create a combobox using wizard and choose the third option from the wizard(Display a record....) You don't need a command button, just choose the number from the combo or type into it and press enter.
I hope the form is bound to a table/query.

________________________________________
Zameer Abdulla
Visit Me
Minds are like parachutes. They only function when they are open. -Sir James Dewar (1877-1925)
 
You don't need to code anything. If you create it with wizard then Access will do everything(coding) for you.

________________________________________
Zameer Abdulla
Visit Me
Minds are like parachutes. They only function when they are open. -Sir James Dewar (1877-1925)
 
I am putting this combobox on a separate form that contains several different types of searching the records. So onEnter i will have to make it open the required form with the record i searched for
 
Something like this AfterUpdateEvent of the combo?
Code:
    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "[b][COLOR=blue]YourSecondFormName[/color][/b]"
    
    stLinkCriteria = "[QuoteNumber]=" & Me![[b][COLOR=blue]SearchComboBoxName[/color][/b]]
    DoCmd.OpenForm stDocName, , , stLinkCriteria
Remember to change the "names"

________________________________________
Zameer Abdulla
Visit Me
Minds are like parachutes. They only function when they are open. -Sir James Dewar (1877-1925)
 
I'm not quite getting it to work, the problem i think is that the form has a subform whose elements are also referenced by quote number, this is not putting any records in the subform (records are needed in the subform for another part of my code)
 
Is your main form bringing any result? What is the datatype of the QuoteNumber (Numeric/Text)?
for numeric code below
Code:
stLinkCriteria = "[QuoteNumber]=" & Me![SearchComboBoxName]
or text
Code:
stLinkCriteria = "[QuoteNumber]=" & "'" & Me![SearchComboBoxName] & "'"


________________________________________
Zameer Abdulla
Visit Me
Minds are like parachutes. They only function when they are open. -Sir James Dewar (1877-1925)
 
QuoteNumber is an autonumber and i am not getting anything on the main form either, only the header.

I have
Private Sub GetQuoteNo2_Enter()
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "HUNZA Quotes"
stLinkCriteria = "[QuoteNo]=" & Me![GetQuoteNo2]
DoCmd.OpenForm stDocName
End Sub

the correct form opens but it is still displaying the first record rather than the one i searched for, i am sure all of the variable names are correct??? puzzled
 
change enter event to AfterUpdate Event of the combo
Private Sub GetQuoteNo2_Enter()
to
Private Sub GetQuoteNo2_AfterUpdate()



________________________________________
Zameer Abdulla
Visit Me
Minds are like parachutes. They only function when they are open. -Sir James Dewar (1877-1925)
 
it's still only displaying the first record. Must be a silly mistake i'm overlooking.
Could it be anything to do with the relationships i've set up
 
Code:
Private Sub GetQuoteNo2_AfterUpdate()
    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "HUNZA Quotes"
    stLinkCriteria = "[QuoteNo]=" & Me![GetQuoteNo2]
    DoCmd.OpenForm stDocName[b], , , stLinkCriteria[/b]
End Sub
???

________________________________________
Zameer Abdulla
Visit Me
Minds are like parachutes. They only function when they are open. -Sir James Dewar (1877-1925)
 
Ok now only the header is displayed and i get error# 2455 saying that You entered an expression that has an invalid reference to a property Form/Report

Thanks a lot for your help
Appreciated Muchly
 
I dont think it is related to this code. Probably something in the second form. Look the code/properties of the second form if there is any mistake. also check the Master-Subform relation.

________________________________________
Zameer Abdulla
Visit Me
Minds are like parachutes. They only function when they are open. -Sir James Dewar (1877-1925)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top