Modules & VBA :: Setting Focus On A Control In Report?

Sep 24, 2013

Windows vista
access 2007

I'm populating a report with a query which pulls criteria from a form. When the 'run' button is pressed it opens the report, running the query, to filter the data. What i'm attempting (and it works if there is data present).

The data is text, which is a filename, which populates an image control. Most of my records have an image present but for the ones that don't I think I need to turn the image control's picture property to 'blank'.

I'm just now encountering problems with the records with no pictures so when i came up with this it worked with my tests which at that time only had images present....

I have two problems.

1) When I run the code as below i get Run-Time Error 2185; you can't reference a property or method for a control unless the control has the focus.

2) when i try to set the focus on the picture control in the report to see if there is text/value present i get runtime error 2478; database doesn't allow you to use this method in the current view.

I assume this is talking about me opening the report in acViewPreview mode but i thought i needed to do this so the images are displayed in the image control.

Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim strDBPath As String
Dim strRelativePath As String
Dim strPath As String
'rptOriginalOwnerCategoryItem!Picture.Text.SetFocus
[B]Me!Picture.SetFocus[B]
'Test to see if the record has a relative path stored

[code]....

View Replies


ADVERTISEMENT

Modules & VBA :: Incrementing A Value And Setting Focus On A Field

Jan 13, 2015

I am new to Access and to the forum. I made a check printing system

table name = 'burgan'
form name = 'burgan cheque'
Fields = 'PV' and 'cheque' and 'Beneficiary'

I have inserted a button (Command31).The function I would like to add on clicking the button

1. it should chose the highest value in both fields (PV and cheque)
2. Create new record
3. Increment it by 1 (both fields 'PV' and 'cheque')
4. the focus should stand on 'Beneficiary' field.

View 3 Replies View Related

Modules & VBA :: Setting Focus To Non Default Instance Of A Form

Mar 21, 2014

How to set focus to a non Default instance of a form.

Environment
A2007 ADP Project
Document Window Option - Tabbed Documents
MS SQL 2012 Express DB
Windows 7 64 Bit

I using Allen Browne's method to open more that one version of form, storing each form object in a collection declared in a module. No problem there.

Now I'm trying to add a command button on an form to set focus to one of these non-default instances already open.

The form I am trying to set focus to has a the following related properties

Default View: Split Form
Pop-up: No
Modal: No

The form that has the command button on it is of the same type.

Here is the code I've tried:

'Code on Calling Form
Private Sub cmdProjectList_Click()
Dim FunctionResult As Boolean

If AppForms.GoToForm("ProjectList") = False Then
AppForms.Load_ProjectList

[Code] .....

The code compiles and executes with seemingly no problems. It finds the form loaded, then cycles though and finds the form in Forms but the SetFocus call seems to do nothing. When I run the code against a defualt instance ( one not opened using Allen Browne's method) it works fine and sets focus to it as expected.

View 11 Replies View Related

Forms :: Setting Focus To Control On Single Form Side Of Split Form

Jun 24, 2013

When I right click a row on the data sheet side of a split form an select "New Record" I want the curser to go to the first field on the single record side. I've placed this in the OnCurrent but it did no good.

Code:

If Me.NewRecord Then
Me!Descrfiption.SetFocus.
End If

Any way to set the focus to the single form Side of a split form?

View 4 Replies View Related

Modules & VBA :: How To Know When Control Has Focus

Sep 12, 2013

In the following code, i am trying to determine if command button has the focus:

Private Sub lstOrg_LostFocus()
If Me.cmdEditOrgProfile_GotFocus() Then
Exit Sub
Else
Me.cmdEditOrgProfile.Enabled = False
End If
End Sub

The second line returns error.

How would I know if a control has the focus?

View 2 Replies View Related

Modules & VBA :: Set Focus On Control After Update

Jan 15, 2015

I have a continuous form populated with a pivot view from SQL. When I enter data in the form I send the data to SQL (ctrl after_update) and then re-populate the form. It works.

When I have entered data in a ctrl - then I have to bookmark the record so I can select it again (find_first). I can "save" the location of the control where I have entered data, but I want to select the location where the user has set focus - which triggered the ctrl after_update..My ctrl after_update looks like this:

Code:
txt_account = Me.Parent.txt_account_id.Value
txt_cost_center = Me.ActiveControl.Name
Call update_data_input(Me.ActiveControl.Value, Me.account_id.Value, Me.ActiveControl.Name)

[code]....

View 6 Replies View Related

Modules & VBA :: Focus To Be Set To First Control Without Displayed Record Being Changed

Jul 31, 2013

On a form (default view: Single), I have a bunch of bound controls that display one record at a time from tblMain. I have a bunch of unbound controls as well (buttons).

If the user tabs through all the controls, reaches the last one (btnLast), and presses tab again, the focus is set to the first control (btnFirst) and the bound controls change to display the next record. I just want the focus to be set to the first control without the displayed record being changed.So I set up an "If" statement in Private Sub btnFirst_GotFocus()

Code:

If Screen.PreviousControl.Name = "btnLast" Then
[code to change record back to previous record]
End If

But btnFirst gets the focus when the form opens, so Screen.PreviousControl spits out an error.I've accommodated this like so:

Code:

On Error GoTo ErrorHandler
If Screen.PreviousControl.Name = "btnLast" Then
[code to change record back to previous record]
End If
Exit Sub
ErrorHandler:
Exit Sub

View 2 Replies View Related

Unbound Report - Setting Control Values

Oct 25, 2005

I have a very simple report - just one field.

I have a Form - "Cases". The button to open the report is on that form as are the values I want in the report.

I want to pull the value of Case Name and Case Number from the current form view and put them together in the single field on my report.

I can "almost" do it. Then VBA gives me a warning - it says that you can't assign a value to the control on my report.

Can anyone give me any ideas?

by the way:
I chose to make this an unbound report because I'm using SQL server as my back-end and my Access is an .adp file. SQL (so I was told by the programmers at work) can't pull in variable criteria from a form like Access Queries can. So this all has to be put in VBA.

View 5 Replies View Related

Modules & VBA :: Setting DateTime Control Default Value

Nov 19, 2014

I am having an issue setting an instantiated forms' control. I am having RemDate ("Date") and RemTime ("Time") TextBox; so far the date textbox shows 1/1/1988 12:00 AM (the visible value is the time only) and the Time textbox doesn't show anything.

Code:
Set frm = New Form_ReminderAssigneesFrm
frm.RecordSource = "Select * from ReminderAssignees Where RemID = " & Parent.RemID
frm.RemID.DefaultValue = Parent.RemID
With SetRS(frm.RecordSource)
If Not .EOF Then
frm.RemDate.DefaultValue = FormatDateTime(.Fields("RemDate"), vbShortDate)

[Code] ....

View 2 Replies View Related

Modules & VBA :: Setting Control Source For Entire Form?

Oct 21, 2013

Is there a way to set the control source for an entire form through VBA? I have a database that was set up just as an archive file, not intending to have any forms or reports in it. It was simply to house tables containing data from previous years. My main database just copies the table over to the archive file and adds the year to the table name. I have just been told that the users would like a form and a series of reports set up in this database.

I would like to set the main form up so that before it will allow them to do anything, they have to enter the year of the data they are looking for. After the year has been entered, I would like to adjust the control source of the form to reflect the appropriate table. In other words, when a user opens the archived database, he or she will see a field for the year an nothing else. Once they enter the year they are looking for, the form will populate with data from the corresponding table (the table names look like this - tblPM_Completed_2013). Is this possible?

View 6 Replies View Related

Setting Focus On Tab

Apr 11, 2008

Hi everyone,

how would i go about setting focus on a tab control? i have a tab control on a form with 6 tab pages. i am on page 4 ( bank ) and i have a button to add a bank account. this opens up the add form and i add the account. i then requery the form and the tab goes back to page 1. how do i set the focus back to the previous opened tab?

many thanks,


Nigel

View 2 Replies View Related

Setting Focus

May 30, 2006

i have a tabular form, which on its after update event, i requery the form, and it works fine. However, my only problem is that after the requery occurs, the focus moves to the first field of the first record. Is there a way in which after the requery, the focus will be set at the end, in that blank record, where to insert a new record ?

Thanks

View 14 Replies View Related

Setting Focus On A Tabbed Form

Oct 12, 2006

What is the syntax for defining the tab that has focus when a tabbed form is opened under various situations?

View 2 Replies View Related

General :: Setting Focus On Forms

Jun 26, 2015

I am having trouble setting the focus on my forms... I have a parent form with two labels that are coded like this.

Private Sub Advisory Messages_Click()
Me![ Advisory Messages].Visible = _
Not Me![Advisory Messages].Visible
End Sub

[code]...

I have the visible property set to no on the subform allowing the user to toggle the visibility when the label is clicked. The problem though is when I click inside the subform to use the scroll bar to view records, it transfers the focus to the subform making it almost impossible to close by clicking the label again because the label is on the parent form. I found the "me.parent.setfocus" command and a few other set focus commands but I don't know what I should be applying the command to in order to make it work.

View 3 Replies View Related

Possible To Scroll Through List Box Without Setting Focus?

Mar 1, 2014

it is possible to be able to scroll through a List Box with just a mouse over? Or, do you need to set focus on the ListBox before being able to scroll?

View 8 Replies View Related

Forms :: Tabbing And Setting Focus On A Button?

Oct 21, 2013

I have a form with a tab control on it. The input for respective fields are placed inside the tab control, and I have the "Confirm" button placed outside, on the main form. Now I wanted to be able to navigate my focus from a control from inside to tab control, out to the Confirm button on the form, to allow smooth flowing data entry.

However, it seems like Access separates the tab indexes for the controls in the tab control and outside on the main form, so setting tab index does not work. I tried using the code ON LOST FOCUS and SET FOCUS;

Private Sub txtPurchaseNote_LostFocus()
Forms![frm Imported]![cmdConfirmPurchase].SetFocus
End Sub

But then a dialog box appears:

Run-time error '2110'
Microsoft access can't move focus to the control cmdConfirmPurchase

(cmdConfirmPurchase is a button control)

View 2 Replies View Related

Forms :: Setting Form Focus Properly?

Jul 10, 2014

I have a Main Form with a tab control. On each of the six tabs is a SubForm that takes up the entire tab. So basically I have a tabbed interface for my forms, just with a bit more control over the layout than if I just opened the forms separately in the Access window.

Anyway, on one of those subforms is a button. When you click it, it opens a separate form in a pop-up window, which is used to find a specific record. Once that record is found, you can click another button, and the idea is that this pop-up window closes, and you return to the underlying form, which jumps to the record you selected.

So far so good. Now, if I am working on my program in Access, and I open that subform's source form separately in its own tab, click the icon to open the record finding form, find a record, and then click the button to load that record, the following code runs, and it runs flawlessly - closing the pop-up window, and passing the information back to the main form which displays the proper record:

Quote:

Private Sub ViewRecord_Click()
Dim RecordID As Integer
RecordID = Me.ID
DoCmd.OpenForm "CDLExam", , , "ID = " & RecordID
DoCmd.Close acForm, "CDLExamCONT", acSaveNo
End Sub

Where my program falls apart is that, in actual use, this form is not open on its own. It's open as a subform on one tab of a tab control on a Main Form. So the third line of code falls apart. Access thinks I want to open CDLExam separately, but it can't because it's already open in the subform, so instead I just end up back at the main window like I want, but the form fails to move to the proper record. Basically, line 3 just doesn't do anything.

How can I make this work? I tried replacing "CDLExam" with the name of the main window, but then it tries to move to the record in the main window, which throws an error as the main window doesn't even have a record source attached to it.

how to refer to the SUBFORM which has CDLExam open, and tell THAT to move to the proper record.

View 14 Replies View Related

Modules & VBA :: Setting Filter Property Via On Open Event Of A Report

Dec 15, 2014

I have a report, on a control tab, on a main form.

On the form are two buttons: one to show all items, and one to filter them based on a boolean field called showitem.

The buttons work with the code below.

What I want to do but cannot seem to figure out is to have the report default to no filter.

The bound query has no criteria.

I'm trying to set the filter property via the on open or on load event and even if I isolate the report, cannot seem to reach it.

Code:
Private Sub b_hide_items_Click()
Me.Profile_Timeline_wNotes_subreport.Report.Filter = "timeline.showItem <> 1"
Me.Profile_Timeline_wNotes_subreport.Report.FilterOn = True
Me.Profile_Timeline_wNotes_subreport.Requery
End Sub

Private Sub b_show_all_Click()
Me.Profile_Timeline_wNotes_subreport.Report.Filter = "timeline.showItem = 0"
Me.Profile_Timeline_wNotes_subreport.Report.FilterOn = False
Me.Profile_Timeline_wNotes_subreport.Requery
End Sub

View 14 Replies View Related

Modules & VBA :: Generate Report For A Test And Answer Sheet - Setting Title?

Oct 15, 2013

I'm using VBA code to open a query, generate a report for a test and an answersheet. I'm using the same report, and don't want to make many reports. I have the below code which runs my query, and generates the reports.

Private Sub Command2_Click()
DoCmd.SetWarnings False
DoCmd.OpenQuery "1", acViewNormal, acEdit
DoCmd.OpenReport "WrittenExam", acViewPreview, "", "", acNormal
DoCmd.OpenReport "WrittenExamAnswerSheet", acViewPreview, "", "", acNormal
End Sub

I have a need to be able to set the report title for both reports when running my code.

View 3 Replies View Related

Get Focus On A Control

Apr 29, 2005

Hi

I would like a control to have focus when a form is opened or press a button - how do i do this?

Many Thanks

View 1 Replies View Related

Control Focus

Oct 10, 2006

Hi all

when i double click on a control that stores a date, i open a active x calendar that i use on a pop up form. (i think its the cal.ocx in access 2003).

I have a few date boxes on my unbound form and i want to use the same calendar popup.

when the popup opens the focus moves to the calendar. i'm trying to put the date into the control i originally double click in.

Any ideas are much appreciated.

View 13 Replies View Related

Focus On Key Control

Sep 7, 2011

The following is contained within a Public Sub cmdSave_Click().Put focus on "key" control...Please define what is ""key" control"?

View 1 Replies View Related

Trying To Hide Control That Has The Focus

Aug 30, 2006

Hi,

I tried hiding a list control by setting its visible property to Flase in VB; however, it keeps returning a message: You can't hide a control that has the focus.

I don't know who to move the focus from my list control before hiding it. I searched in the MSDN online, but with no luck.

Any help will be very much appreciated.
Thanks,
B

View 8 Replies View Related

Can't Move The Focus To The Control

Nov 7, 2007

Hi

I am trying to write simple code that undoes entering a new record and moves the focus to a mandatory field. I wrote the code below; however, I get this run time error message each time I run it.

DB can't move the focus to the control PlotNum.

My code:
Private Sub cmbHouseType_BeforeUpdate(Cancel As Integer)
Forms![frmHouse]![qryHouse2]![PlotNum].SetFocus
If Forms![frmHouse]![qryHouse2]![PlotNum].Text = "" Then
Cancel = True
Me.Undo
MsgBox "Please enter the Plot Number first, then enter the House Type"
End If
End Sub

Any help will be very much appreciated
B

View 4 Replies View Related

Disable A Control While It Has The Focus

Jul 21, 2006

I understand that I cannot change control.enabled to false while the control has focus.

Does this mean that if I were to make a form with only one control that can have focus then I cannot disable said control?

I'm used to plain old VB6 and am unfamiliar with this restriction :mad:

View 3 Replies View Related

Change Focus On Tab Control

Oct 17, 2006

I have a form with 2 tabs and a sub form on each of those tabs. form1, subformA, subformB on tab control - tabctrl - pageA, pageB. How can i set focus from one tab to another without actually clicking the tab?

I tried this:

TabCtl.Pages("page2").SetFocus

It's comming up with an error - "object required"

I also tried:

page.2.setfocus and that's comming up with an error that it's wrong syntax.

I also tried:

formMyForm.page2.setfocus and that says object required as well.

View 7 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved