Computing.Net > Forums > Database > Access 2003 Query help

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Access 2003 Query help

Reply to Message Icon

Name: anthony hart
Date: April 18, 2009 at 11:11:04 Pacific
OS: Windows XP
Subcategory: General
Comment:

I am a bit of a beginner with access but am picking it up pretty quickly. I need to get my form to lookup a structure name and return it to a text box by typing in the corresponding structure no. I have all the details in a query but not sure what to do next.
Thanks



Sponsored Link
Ads by Google

Response Number 1
Name: Hviezdoslav
Date: April 24, 2009 at 11:59:04 Pacific
Reply:

Could you show please what VBA code you have at this point, Anthony?


0

Response Number 2
Name: Hviezdoslav
Date: April 24, 2009 at 12:06:02 Pacific
Reply:

Anthony, does this help you in some way by chance?

 Dim db As DAO.Database
 Dim rs As DAO.Recordset
Dim strSQL As String
 Dim strList As String
 
Set db = CurrentDb
 
strSQL = "SELECT  Products.ProductName " & _
"FROM    Products " & _
 "INNER JOIN Categories " & _
 "ON  Products.CategoryID      = Categories.CategoryID " & _
 "WHERE Categories.CategoryName='Beverages'; "
 
Set rs = db.OpenRecordset(strSQL, dbOpenDynaset)
With rs
Do While Not .EOF
strList = strList & rs!ProductName & ", "
.MoveNext
Loop
End With
 
 'Trim last comma
 If Right(strList, 2) = ", " Then
strList = Left(strList, Len(strList) - 2)
End If
 
Me.Text0 = strList
Set rs = Nothing
Set db = Nothing

In the VBA code, you can basically run your query and put the result(s) of the query into a record set. Then you can do whatever with the record set.

Me.txtBoxName.Text = rs!NameOfFieldFromQueryResult

I do not know though if I understand your situation correctly.


0

Response Number 3
Name: Hviezdoslav
Date: April 24, 2009 at 12:24:06 Pacific
Reply:

Or maybe

formName.txt_NameOfTextBox.Value = rs!NameOfFieldInQuery 


0

Response Number 4
Name: krishna77
Date: June 17, 2009 at 11:54:45 Pacific
Reply:

Dim dbs As Database, qdf As QueryDef, strSQL As String
Set dbs = CurrentDb

strSQL = "SELECT * FROM All_record_New WHERE (((All_record_New.[Physical Zip - US Only])=[Forms]![All_record1]![ZIP]) AND ((All_record_New.[Est Tot Wireline Communications Bill - Most Likely]) >= [Forms]![All_record1]![Est1] AND (All_record_New.[Est Tot Wireline Communications Bill - Most Likely])<= [Forms]![All_record1]![EST2]) AND ((All_record_New.[Emp Here]) >= [Forms]![All_record1]![EMP1] AND (All_record_New.[Emp Here]) <= [Forms]![All_record1]![EMP2]) AND And ((All_record_New.[Physical Street Address Line 1]) LIKE ('*'+[Forms]![All_record1]![FPA]+'*')));"
Set qdf = dbs.CreateQueryDef("qry" + Forms!All_record1!ZIP, strSQL)
DoCmd.OpenQuery ("qry" + [Forms]![All_record1]![ZIP])


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More






Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: Access 2003 Query help

MS Access 2003 & Time Query www.computing.net/answers/dbase/ms-access-2003-amp-time-query/90.html

summarising in access-using query www.computing.net/answers/dbase/summarising-in-accessusing-query/146.html

MS Access Query Help www.computing.net/answers/dbase/ms-access-query-help/724.html