Populate Unbound Control

rinelson

New member
Local time
Today, 15:05
Joined
Aug 5, 2005
Messages
7
I'm trying to populate an undound text box on a report and here's the code that I have that's not working. I keep getting a Compile Error: Method or Data Member not found. Here's the code, hope you can help....

Code:
      Public Function FillGeneral()
      Dim rs As Recordset
      Dim db As Database
      Dim str As String
      
      str = "SELECT tbl_Structure.ProjectID, " _
            & "tbl_Structure.ContractorID " _
            & "FROM tbl_Structure WHERE (((tbl_Structure.ParentContractorID) " _
            & "Is Null));"

      Set db = CurrentDb()
      Set rs = db.OpenRecordset(str, dbOpenDynaset)

      rs.MoveFirst
      rs.FindFirst "= ProjectID" & Reports![report1]![ProjectID]

      FillGeneral = rs![ContractorID]
      End Function
 
Try these changes:
Code:
Set db = CurrentDb()
Set rs = db.OpenRecordset(str, dbOpenDynaset)

[COLOR=Red]'rs.MoveFirst <-- do not need this line[/COLOR]
[COLOR=Red]'rs.FindFirst "[ProjectID] = '" & Reports![report1]![ProjectID] & "'" '--If Text [/COLOR]
rs.FindFirst "[ProjectID] = " & Reports![report1]![ProjectID] '-- If Numeric
If Not rs.NoMatch Then
   FillGeneral = rs![ContractorID]
End If

[B]Set rs = Nothing[/B]
End Function
 
Still not there

Ruralguy,

Thanks for the code sample! I tried it both ways (text & numeric) but still getting the same darn error. I know that I'm an extreme rookie but this is driving me crazy. Here is the actual database...
 

Attachments

Here's the mdb back with some changes. Lookup Fields in tables only confuse the developer. They are rarely of any help. Your fields were numeric as you can see now that I removed the lookups and turned them back into textboxes. I removed ADO from your references so the DAO would work properly. At least Report1 no longer throws an error and your FillGeneral function runs. Hope that has helped a little.
 

Attachments

Ruralguy!!! I can't thank you enough! I've only been on this site for a little while and already have benefitted greatly because of folks like you. I only hope that I'll be able to get better so that I can contribute back.

Thank you sir.

Rich
 

Users who are viewing this thread

Back
Top Bottom