473,395 Members | 1,422 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

VB in Access 2013

22
I am trying to use the where condition to assign the caption to the form I am opening through DoCmd.OpenForm triggered by command button OnClick.
This form is a template I assign 4 different record sources (you'll see in part of the code), the caption in property sheet is blank.
I would like it to show me different captions depending on the button I pushed to open
Sample code of two of the buttons I've written so far:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdCO_Click()
  2.    DoCmd.OpenForm "qdffrmINVMF3713", , , Form.Caption = "Cost Open"
  3.    Forms!qdffrmINVMF3713.RecordSource = "qryISSUE1costopen"
  4. End Sub
  5.  
  6. Private Sub cmdPP_Click()
  7.     DoCmd.OpenForm "qdffrmINVMF3713", , , Form.Caption = "Partial Payments"
  8.    Forms!qdffrmINVMF3713.RecordSource = "qryISSUE2ppfrm"
  9.  
  10. End Sub
(I also tried Me.Caption but that didn't work)

Form is opening with proper record source, but I can't get the where to trigger
Imagine I am missing syntax?

Thank you!
Sep 13 '18 #1
2 1227
Nauticalgent
100 64KB
On the form's OnOpen event, try:
Expand|Select|Wrap|Line Numbers
  1. Select Case Me.RecordSource
  2.      Case "qryISSUE1costopen"
  3.           Me.Caption = "Cost Open"
  4.      Case "qryISSUE2ppfrm"
  5.           Me.Caption = "Partial Payments"
  6.      Case Else
  7. End Select
  8.  
Sep 14 '18 #2
NeoPa
32,556 Expert Mod 16PB
You seem to imagine that you can simply write an expression after a few commas (,) and the procedure will necessarily process that for you intelligently. It really doesn't work that way at all.

DoCmd.OpenForm() has a set of parameters, many of which are optional. The seventh parameter is called OpenArgs and can be used to pass a string across to the Form. Let's forget about positional parameters though (See How to Use Named Arguments). They're just a problem waiting to happen for procedures like this one.
Use something like :
Expand|Select|Wrap|Line Numbers
  1. Call DoCmd.OpenForm(FormName:="qdffrmINVMF3713" _
  2.                   , OpenArgs:="qryISSUE1costopen;Cost Open")
That way, in your Form_Open() event procedure you can include :
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Open(Cancel As Integer)
  2.     Dim astrOA() As String
  3.  
  4.     With Me
  5.         astrOA = Split(Nz(.OpenArgs, ""), ";")
  6.         If UBound(astrOA) < 1 Then
  7.             Cancel = True
  8.             'Error message if required.
  9.             Exit Sub
  10.         End If
  11.         .RecordSource = astrOA(0)
  12.         .Caption = astrOA(1)
  13.     End With
  14. End Sub
Sep 14 '18 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: steveradaza | last post by:
Sir,Good Day..I am a newbie here and i am just learning the usage of microsoft access..can you help me solve my problem in making a running balance in a query of microsoft access 2013 of my In and...
4
by: nomeepk | last post by:
hi, i am using access 2013, Is there a way i can make this Access Database online, so i can access and use it from anywhere in a Browser? Regards.
5
by: jimatqsi | last post by:
I'm looking for information about compatibility between Access 2013 and Access 2003. I've been approached by a firm that wants to begin upgrading their systems. I want to know if it is reasonable...
0
by: LeoVBNET | last post by:
Hi Because VS 2013 dropped SQL COMPACT databases, I need to convert Access 2013 databases into SQL COMPACT in order to be able to use Linq to SQL in VB 2013. Anybody can help me? Thanks
6
by: GKJR | last post by:
I have been using Access 2013 (in Office 365) with Windows 8.1 for about a month and a half now. I was a little reluctant to switch from 2010 on Windows 7, but I figured I should try stay ahead of...
6
by: msilva100 | last post by:
Hello, I need to have remote access to a MS Access 2013 Database running on a Windows 7 Server. Can someone kindly recommend a remote access tool? Thank you.
1
by: msilva100 | last post by:
Is it possible to split a Runtime MS Access 2013 database? I am on a Windows 7 server. I have one license of MS Access 2013. But I would like distribute this application to 5 client workstations. ...
7
by: jalbright1957 | last post by:
We have Office365 / Sharepoint online / Exchange online in our organization. I am the only one with the E3 subscription which gives me Access. I have a database that needs to be made available to...
1
by: tallen | last post by:
ADezii and zmbd, I have one other question. There seems to be some other code which possibly should reflect the new DAO code. the following does not allow forms to open any longer and files were...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.