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

FindRecord problem 1

Status
Not open for further replies.

BrenoAguiar

IS-IT--Management
Feb 8, 2005
81
0
0
US
I'm having a problem with the following code that it seems to work but it does not find and Display the field searched. This is a form that you update records and once you submit the changes, it requeries another form and it is supose to find the record updated. here is the Code:


DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
[Forms]![addmedia].Requery
[Forms]![addmedia].RecordsetClone.FindFirst " Mediadetails![Media_cd] = " & Me![Media_cd]
DoCmd.Close acForm, "editmdetails"


I tried the .Bookmark but with no success. Any help?/
 
Hi, BrenoAguiar,
BrenoAguiar said:
[Forms]![addmedia].RecordsetClone.FindFirst [red]" Mediadetails![/red][Media_cd] = " & Me![Media_cd]
Looks like you have an extraneous space character immediately before Mediadetails that I think will cause a problem. Also, not sure the bang operator will work after Mediadetails; try the dot instead. One final item: Is [Media_cd] numeric or text? If it is a text value, you need to enclose it in single quotes. Something like this might work:
Code:
[Forms]![addmedia].RecordsetClone.FindFirst "Mediadetails.[Media_cd] = '" & Me![Media_cd] & "'"
Ken S.
 
And what about this ?
Dim rs As DAO.Recordset
DoCmd.RunCommand acCmdSaveRecord
DoEvents
Forms!addmedia.Requery
Set rs = Forms!addmedia.RecordsetClone
rs.FindFirst "Media_cd='" & Me!Media_cd & "'"
Forms!addmedia.Bookmark = rs.Forms!addmedia
Set rs = Nothing
DoCmd.Close acForm, "editmdetails"

If media_cd is defined as numeric then get rid of the single quotes.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
The media_cd IS a numeric field so I removed the single quotes. What I have now is a "Compile Error - Method or data member not found" and it highlights the

= rs.Forms!

I tried the Brackets but no success neither..
 
OOps, sorry for the typo.
Forms!addmedia.Bookmark = rs.Bookmark

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Awesome! I was trying to understand it before the typo... But it works great now. Thanks PHV!
 
PHV,
how can I tell if the bookmark found something
I want to check to see if an item is n a subform or not
Code:
    ProductName = Forms![frm-InStock Find part]![Instock Query subform].Form![ProductName]
    
    ' define the criteria used for the sync
    SyncCriteria = "[Productname]=" & Chr$(39) & ProductName & Chr$(39)
    ' find the corresponding record in the Parts table
    rs.FindFirst SyncCriteria
    
    Forms![frm-InStock Find part]![Ten List subform].Form.Bookmark = rs.Bookmark
    
    If rs.Bookmark Then
       don't add to list
    else
        add to list
     end if

any ideas?

DougP, MCP, A+
 
Have a look at the NoMatch method:
rs.FindFirst SyncCriteria
If rs.NoMatch Then
'not found
Else
'found
End If

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top