Solved

MSAccess Form Recordsource change

Posted on 2009-05-19
3
434 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 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

737 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