Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

MSAccess Form Recordsource change

Posted on 2009-05-19
3
Medium Priority
?
439 Views
Last Modified: 2013-11-28
Hello,

I am trying to change the recordsource of a form from another form. When the user clicks on the name of the client in the first form, second form should be displayed about the client which was chosen in the first form.
When I try to run this, it says 'it cannot find the frmclientssearchsub2 in the list of forms.
and highlights the
Me!frmClientsSearchSub2.Form.RecordSource = strsql
section.
I suspect the syntax should be different.
thanks,
Private Sub ClientName_DblClick(Cancel As Integer)
Dim strsql As String
 
 
Dim strwhere As String
strsql = "Select * From Assets"
strwhere = "1"
If Not IsNull(Me.Form.ClientName) Then
strwhere = strwhere & " AND LastName= '" & Me.Form.ClientName & "'"
End If
DoCmd.OpenForm ("searchform2")
 
Me!frmClientsSearchSub2.Form.RecordSource = strsql
 
 
 
End Sub

Open in new window

0
Comment
Question by:awesomejohn19
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 2

Expert Comment

by:ctpmn1
ID: 24425800
Is the name of the form you are trying to pull frmClientsSearchSub2 ? If not then you should start there.
0
 

Author Comment

by:awesomejohn19
ID: 24426354
yes the name is frmClientsSearchSub2 and it is inside searchform2
0
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 2000 total points
ID: 24429015
awesomejohn19,

1. I cannot see were you are inserting the word "WHERE" in you SQL?

2. I can even see what Field you are trying to use the "1" for?

3. If all the values in the SQL string are hardcoded, then keep things "Simple" and put them all togeather in one string, so this is "easy" to troubleshoot.

4. You should be referring to the company ID, not the Name.

5. It looks like yor final SQL is Malformed.

6. It is not clear if the  1  is really a text datatype ("1"), or a numeric Datatype (1)

In any event, this works fine for me...

JeffCoachman


Access-EEQ24422068--ChangeFormRe.mdb
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question