Solved

MSAccess Form Recordsource change

Posted on 2009-05-19
3
430 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
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 500 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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
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.

760 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now