Adjust Margin With Vba Code?
Jan 10, 2006I know in access 2003 i can use:
printer.leftmargin = 0
but in access 2000 there is no printer object. Is there a way of setting the margin with vba from access 2000?
I know in access 2003 i can use:
printer.leftmargin = 0
but in access 2000 there is no printer object. Is there a way of setting the margin with vba from access 2000?
Ok, so this one's been driving me batty for some time now. When I create a form in a new database, I can resize the design window to my heart's content, without any adverse effect to the form's rendered size. However, I also work with another database that was not created by me, and whenever I create a new form, the size of the form is entirely dependent on the size of the design window. This is extremely aggravating, as I have to pixel-by-pixel shrink the form renders the correct size. Is there an option somewhere in access or Form formatting to turn this "functionality" off, so that a form will only render the size that I designated to it, and not to its design window?
View 1 Replies View RelatedI am receiving the following error when printing different reports to several different printers in Access 2007: "The section width is greater than the page width, and there are no items in the additional space, so some pages may be blank. For example, the report width may be wider than the page width." According to my co-workers this issue began immediately following the upgrade to version 2007 from 2003.
View 1 Replies View RelatedI am running a very simple query that divides profit over turnover to show the margin. I have many queries throughout my database that do this, here is my little formula;
Margin: Round(([profit]/[Turnover])*100,2)
Now, this runs just fine but if I put in a criteria of <10 I get the division by zero error. The reason I am confused is that there are no zeros or error values or even negative values in either of the profit or turnover columns?
Also I have an almost identical query in another database that has a <5 criteria in it and it works a peach.
I have searched but all I am getting is the usual definition of the division by zero error.
First off, I'm really new to all this so I'm a little overwhelmed. I know what I want but may not describe it well.
I'm just trying to get a basic issue to work.
If I have 2 databases, one which has names, and another which has information - in memo form. What I'm trying to do is create a form which will allow me to bring up a persons name and have the subform query the information database for all information (events) which have this persons name listed inside.
I have tried both filters and queries and while I can get everything to work if I type in text in the queries in and/or filters if I try to use the value of the name in the main form nothing ever works...
Thanks...
Below is code to adjust file attributes.
Code:
Public Shared Sub Main()
Dim path As String = "c: empMyTest.txt"
' Create the file if it exists.
If File.Exists(path) = False Then
File.Create(path)
[Code] .....
How to adjust the column width of the fields to best fit in a Query using vba codes? Manually it can be done by selecting the Query - Click on More dropdown of the Reports section in the ribbon - Click on Column width - and select best fit as the option.I want this to happen by a vba code and not manually doing it everytime because the field length changes as it is a dynamically created Query.
View 3 Replies View RelatedI am trying to make the + - (numpad) adjust the date of the current text field. The problem I am having is I believe the input mask intercepts the keypress and my keypress event is never fired. Here is my code:
Code:
Private Sub LeaseDate_KeyDown(KeyCode As Integer, Shift As Integer)If (KeyAscii = 107) Then
LeaseDate = DateAdd("d", 1, LeaseDate)
End If
If (KeyAscii = 109) Then
LeaseDate = DateAdd("d", -1, LeaseDate)
End If
End Sub
Access makes the ding noise when I try and press + and - ...
Hello,
I have two tables: COSTING and PRICING, both with the following fields:
product name French
packaging
transportation
ddp
I want to create a query so that from a text box in the pricing form the user could enter a desired "margin" (ie. 10%) and the query would replace everything in the pricing table with the data from the costing table multiplied times the margin entered in the text box.
how can i accomplish this???
so far i can update the pricing table with the costing data with a action (update) query, but im still missing how to integrate the user "margin" input. At the same time i have the problem that the query limits the update only to the products that are ALREADY in the pricing table. So it doesn't copy ALL the products from the Costing table.
Thanks,
Gilberto
I'm going crazy!! Someone who didn't really understand relational database theory (not like I'm an expert, but. . .) built a DB that is much more complicated than it needs to be. That person left and I got the job. I have to work with our IT people to hopefully redesign it completely (I would without asking, but they control the SQL server and the connection to the web.) but in the meantime, I have to work with a mess.
Okay, the question--I have to print a report of which organizations used which software company.
The table fields are:
Organization
Comp1
Comp2
Comp3
Comp4
etc.
the answers are a "1" for a yes and a "0" for no in the "Comp" fields, so there is an answer in every field of a record. Essentially, it's a spreadsheet.
Off the top of my head, I know I could query each Company name with the court individually and then union query them all together. But isn't there any easier way? We're talking about 15 queries if I do it that way!
Anyway, thanks for any help you can give--this is driving me crazy (over 40 table set up in similar disarray. . . .)
I have created a form using Create|Form.
I have now opened it in Design view and wish to adjust the width of the controls - text boxes etc but when I try to adjust one, all of the text boxes in that column are adjusted.
How do I individually adjust the widths?
I've created an Access Report of a letter to be printed and mailed to customers. The majority of the letter is text, however there is a subform in the middle that will have a wide range of records displayed in it. This causes the subform's height to adjust from 1/2" to several inches, depending on the number of records. I need the text below the subform to start just below the last record in the subform, no matter how many records are displayed in the subform.
Access 2010
How can I adjust my required field so that you cannot simply enter a space bar character to circumvent the requirement?
Here is part of the code:
If IsNull([txtRequiredReason]) Then
MsgBox "The Reason field is required"
DoCmd.GoToControl "txtRequiredReason"
Else
I have a database that I use to put in orders for our shop and keep track of our part informations as well as paint and packing materials. Everything works good on this but I am trying to create a table for adjusting quantities on hand for packing material based on the part quantities and for adjusting paint in stock based on information given to me after the job is run.
There is already a relationship between parts and packing material as well as parts and paint. When I put an order in I would like to have it adjust out that many packing materials that are related to that part. Once a job is run I need to be able to adjust out the amount of paint used.
For the paint side of this I want it to track the paint used by order, we are trying to get a grasp on how much paint we are using for parts so it is important for me to know how much and when.
I am thinking I need a table that connects paint to orders and has quantities in it, then create a query and do the calculations from there... I do not know how to accomplish that but it sounds like it could be right...
I would like to make some changes to the Northwind sample database.I need to have the Customers section completely removed as my company issues products to our own staff, not to external customers, so there is no Customers and shipping details needed.
View 2 Replies View RelatedI have set up a report in Access. However, when I look at it in print preview, I get the message that the section width is greater than the page width, and that some pages will be blank. It is obvious that the Detail Section is the issue, but I can't figure out how to reduce the section width. The detail section only contains a few text boxes that are well within the margins of the other sections.
How do I adjust the section width so there won't be any blank pages?
I have subform (Datasheet) is there some code e.g. after update, which can adjust size cell to lenght of data?
View 11 Replies View RelatedIs it possible to make it so that whatever the dimensions of the image i paste the OLE object's frame will also be the same? I'm having a problem, not necessarily a problem more like a preference, I'm inserting pictures of each individual inside a database and whomever last took these pictures didn't make sure there was a standard size So all the images are different sizes and when they're put inside the OLE frame you can see the image inside it but the frame itself also shows its white background because the image isn't the full dimensions of the frame. I was thinking if it's possible to make the frame automatically adjust to the image's width & height.
View 3 Replies View RelatedIs it possible on the Find Record button added to a form to adjust the search function so it defaults to a specific box on the form? I have a form for tracking employee's and on my Find Record button I would like it to default to the Last name instead of the Record number.
View 3 Replies View RelatedWorks great, but when I hit the number "3", (3 times in row) it will let me into the form. I want it to not let me in IF I don't know the password.
Where did I go wrong?
Private Sub Form_Load()
Dim pw As Variant
If InputBox("What is the password?", "Password") = "1" Then
Else
MsgBox "Invalid Password", vbCritical, "Sorry Charlie"
DoCmd.Close
If InputBox("What is the password?", "Password") = "2" Then
Else
MsgBox "Invalid Password", vbCritical, "Sorry Charlie"
DoCmd.Close
End If
End If
End Sub
I protect my code from people being able to read it by setting a password on the code from Tools > Properties, selecting the Protection tab and entering a password, and clicking "Lock Project"
Is there a way to write code that will remove that Lock Project check and check it back on?
I've looked through the Application.SetOption command and it doesn't seem to be one of the choices. It would be very helpful if someone knew how to do this.
Thanks
SHADOW
I have a button that runs a macro to insert NOW() into a text box.
This is how it is coded;
Private Sub Start_transferred_job_button_Click()
On Error GoTo Err_Start_transferred_job_button_Click
Dim stDocName As String
stDocName = "Start transfered job"
DoCmd.RunMacro stDocName
Exit_Start_transferred_job_button_Click:
Exit Sub
Err_Start_transferred_job_button_Click:
MsgBox Err.Description
Resume Exit_Start_transferred_job_button_Click
End Sub
How do I write the code to populate the [start Time] text box with NOW() when the button is clicked without using a macro???
Need a little help here. I have this code on a command button that open a form that displays a chart. The chart work great as long as there is data to display. However, if there is no data then the chart is blank. So what I'm trying to do is add a dcount to catch the 0 and give an error. So the 1st query makes the table where the data for the chart come from. The Qry-Test for Zero query, queries that new table if dcount is 0 it should error.
My problem is that I can't get this to work with the 0 if I make it 1 then I will get the message box if there are no records and if there is 1 record 2 and greater work fine. So my question is why won't the code catch the 0?
Dim stDocName As String
stDocName = "Qry-Makes Table"
DoCmd.OpenQuery stDocName, acNormal ', acEdit
If DCount(" * ", "Qry-Test for Zero") = 0 Then
MsgBox " There is no data for this time frame to chart. Please re-enter your Date range"
Exit Sub
Else
Thanks
jon
Need a little help here. I have this code on a command button that open a form that displays a chart. The chart work great as long as there is data to display. However, if there is no data then the chart is blank. So what I'm trying to do is add a dcount to catch the 0 and give an error. So the 1st query makes the table where the data for the chart come from. The Qry-Test for Zero query, queries that new table if dcount is 0 it should error.
My problem is that I can't get this to work with the 0 if I make it 1 then I will get the message box if there are no records and if there is 1 record 2 and greater work fine. So my question is why won't the code catch the 0?
Dim stDocName As String
stDocName = "Qry-Makes Table"
DoCmd.OpenQuery stDocName, acNormal ', acEdit
If DCount(" * ", "Qry-Test for Zero") = 0 Then
MsgBox " There is no data for this time frame to chart. Please re-enter your Date range"
Exit Sub
Else
Thanks
jon
I use the code below on a search form. I would like for the results of the list box search to populate a report instead of the list box. Is it possible to take the the sql and move it to a report? Thanks..
Dim strsql As String, strOrder As String, strWhere As String
Dim dbNm As Database
Dim qryDef As QueryDef
Set dbNm = CurrentDb()
strsql = "SELECT SiteIssues_tbl.IssueID, SiteIssues_tbl.SITE_ID, SiteIssues_tbl.IssueID, SiteIssues_tbl.AdminDate, SiteIssues_tbl.Occurring, SiteIssues_tbl.Issue, SiteIssues_tbl.Administrative, SiteIssues_tbl.Technical, SiteIssues_tbl.IssueComments, SiteIssues_tbl.CandidatesAffected, SiteIssues_tbl.RecordCreated, SiteIssues_tbl.User, SiteIssues_tbl.DateModified " & _
"FROM SiteIssues_tbl"
strWhere = "WHERE"
strOrder = "ORDER BY SiteIssues_tbl.AdminDate;"
'Set the WHERE clause for the QueryDef if information has been entered into a field on the form
If Not IsNull(Me.txtIssue) Then '<--If the textbox txtCenterName contains no data THEN do nothing
strWhere = strWhere & " (SiteIssues_tbl.Issue) Like '*" & Me.txtIssue & "*' AND" '<--otherwise, apply the LIKE statment to the QueryDef
End If
If Not IsNull(Me.txtAdminDate) Then
strWhere = strWhere & " (SiteIssues_tbl.AdminDate) Like '*" & Me.txtAdminDate & "*' AND"
End If
If Not IsNull(Me.txtSite) Then
strWhere = strWhere & " (SiteIssues_tbl.SITE_ID) Like '*" & Me.txtSite & "*' AND"
End If
'Pass the SQL to the RowSource of the listbox
Me.lstSearchResult.RowSource = strsql & " " & strWhere & "" & strOrder
With Me.lstSearchResult
If .ListCount > 0 Then
GetListCount = .ListCount - 1 'Headings count
Else
GetListCount = 0 'Headings don't count if no items listed!!
End If
Me.Text31 = .ListCount - 1
Dim ctl As Control
End With
If Me.Text31 = -1 Then
Me.Text31.Value = 0
Me.lstSearchResult.RowSource = ""
DoCmd.RepaintObject acForm, "SitesIssues_qry"
Me.Requery
MsgBox "No Records Found."
For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Or ctl.ControlType = acCheckBox Then
ctl.Value = Null
DoCmd.RepaintObject acForm, "SitesIssues_qry"
Me.lstSearchResult.RowSource = ""
Me.Requery
End If
Next ctl
End If
I have written the code below, which should work, however I am receiving an Error: Run Time Error '13' Type mistmatch on line:
Set cn = Application.CurrentProject.Connection.
Can anyone help?
Option Compare Database
Option Explicit
Private Sub cmdRun_Click()
Dim NICode As String
Dim rs As ADODB.Recordset
Dim cn As ADODB.Connection
Dim strSQL As String
Set cn = Application.CurrentProject.Connection
Set rs = New ADODB.Recordset
NICode = "txtLetter"
strSQL = "SELECT " & NICode & "1a, " & NICode & "1b, " & NICode & "1c, " & NICode & "1d & NICode & "1g & NICode & "1h FROM [WorkPlace NI Breakdown]"
rs.Open strSQL, cn
If Not (rs.EOF And rs.BOF) Then
MsgBox rs.Fields(NICode & "1a")
MsgBox rs.Fields(NICode & "1b")
MsgBox rs.Fields(NICode & "1c")
MsgBox rs.Fields(NICode & "1d")
MsgBox rs.Fields(NICode & "1g")
MsgBox rs.Fields(NICode & "1h")
End If
rs.Close
cn.Close
Set rs = Nothing
Set cn = Nothing
End Sub