VB In The Modules

Jan 12, 2007

I’m new to Access and have been looking through a lot of the sample db,s very helpful, am I right in my conclusion that there is a lot of work being carried out in VB in the modules.
I’m reading all sorts of books at the moment and they are not going any ware near this area.
Is this the new 2003 program getting to grips:)

View Replies


ADVERTISEMENT

Use Of ME With Modules

Oct 2, 2006

Hello,

I am getting an error with the Me function if present in modules. Is this because a module is Public?
How can I fix this problem and make the code run in a module?
Thank you.

This code runs an append query before closing a form named form1 and open another form named form2 using the c/n as linking criteria.

I am getting the error with Me.

I am trying to run this module from a menu bar.

thank you for you help.

Dim mydb As DAO.Database, MyRs As DAO.Recordset
Dim strCode As String
Dim strFilter As String
Dim stDocName As String
Dim stLinkCriteria As String

Set mydb = CurrentDb
Set MyRs = mydb.OpenRecordset("list")

stDocName = "form1"

stLinkCriteria = "[c/n]=" & "'" & Me![C/N] & "'"


DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.OpenQuery ("AppendHISTORY")

DoCmd.Close
DoCmd.OpenForm ("form1")




End Sub

View 3 Replies View Related

What Is The Startup Modules?

Aug 7, 2006

Sorry I have to ask such a simple question. I haven't worked on Access for over 10 years.

How do I find out which modules is the startup? Thanks.

DanYeung

View 1 Replies View Related

Access VB Modules

Jan 18, 2005

Hi guys, im working on a project whereby a Visual Basic module has been designed in MS Access to email out a RTF document attachment of reports to shift managers when they have hazard items not closed in their area. Im building an ASP front-end to the database and would like to incorporate a button to do the mailout, however i dont know how i can link it to fire the code when the button is pressed. Is it even possible?

Nath

View 2 Replies View Related

Code In Modules

Aug 25, 2006

Friends,
I need to place a vba code from a regular event in a form to a module so that when the form opens the function in the module is recalled using a macro.
How do I do this?

For example, I have the following code in the OnOpen event of a form:

Dim strInputBox As String, bytChoice As Byte
InputPoint:
strInputBox = InputBox("Please input the password.", "Password Required - Restricted Area! ")
If Len(strInputBox) > 0 Then
If strInputBox <> "***" Then
bytChoice = MsgBox("Wrong password" & vbNewLine & vbNewLine & "Do you want to try another?", vbExclamation + vbYesNo, "Warning")
If bytChoice = vbYes Then
GoTo InputPoint
End If
Else
DoCmd.OpenForm "Maintenance"
End If
End If

I would now like to place this code in a module and run it using a macro.

Any help? Thanks.

View 1 Replies View Related

Modules & VBA :: How To Take A Value From One Form To Another

Jul 7, 2014

I have form called frmplant on open I select plant type from the combo box then there is a sub form called plantitem tbl subform this show's the plant under that type on a continuous form so the user enters the plant information then they have command button to open another form call frmpopupPlantService to log the service history of the plant item the user enters the service date and service notes I have text box call "add" this shows the next service due this is the value I want to add to plantitem tbl subform in the service due date box when frmpopupPlantService form is closed . This what I have tried

Code:
Me.add = [Forms]![frmplant]![PlantItemTbl subform]![ServiceDueDate]
[Forms]![frmplant].Requery

But I get error
run time error
you can't assign this value to a object

Here a sample of my database : shanetest.zip

View 14 Replies View Related

Modules & VBA :: How To Get Day Name Of Date

Feb 23, 2014

I want to know the day name of a date. I am getting type mismatch 13 for this line

PrintingDateDayName = WeekdayName(Weekday(PrintingDate))

So this code is not right. This is my full code

Dim RegisterDate As Date
Dim PrintingDate As Date
Dim PrintingDateDayName As Date
RegisterDate = Me.txt_register_date
PrintingDate = RegisterDate + 180
PrintingDateDayName = WeekdayName(Weekday(PrintingDate))
If PrintingDateDayName = vbSunday Then
MSG1 = MsgBox("It's Sunday", vbOKOnly + vbInformation + vbMsgBoxRtlReading, "Clients Database")
Else
MSG1 = MsgBox("It's Not Sunday", vbOKOnly + vbInformation + vbMsgBoxRtlReading, "Clients Database")
End If

View 8 Replies View Related

Modules & VBA :: AND In Where Condition

May 21, 2014

I got this code to run correctly, which pulls records where they are not junk(can be seen at end of where condition), the only issue is that the "AND" does not turn blue. Is this a problem?

Code:
If Not IsNull(Me.txt_last_rec_id) Then
'DoCmd.SetWarnings = False
SQLText = "INSERT INTO tbl_batt_id " & _
"(record_num, bat_id, manufacture, date_code, barcode, status) " & _
"SELECT " & Me.record_num & ", bat_id , manufacture, Date_Code, barcode, Status " & _
"FROM tbl_batt_id " & _
"WHERE record_num = " & Me.txt_last_rec_id & " And [Status] <> 'Junk'"

[code]....

View 3 Replies View Related

Modules & VBA :: Counting With SQL

Dec 19, 2014

I built a query "WplatyKlienci" which sum all of payments "Sumawplat" from my clients "klient".

Code:

SELECT SUM(tblWycenaZakonczone.cenanetto) AS Sumawplat, tblKlienci.nazwaSkrocona AS klient
FROM tblWycenaZakonczone INNER JOIN (tblZleceniaZakonczone INNER JOIN TblKlienci ON tblZleceniaZakonczone.id_k = tblKlienci.id_k) ON tblWycenaZakonczone.id_zlecenia = tblZleceniaZakonczone.id_zlecenia
WHERE tblWycenaZakonczone.cenanetto is not null
GROUP BY tblKlienci.nazwaskrocona;

Now I need to know 2 things and I have problem with counting in sql:/

1) what percentage of the total amount represents a particular client.
2) I want to create a graph, so I need to do another query, which shows values form no. 1 only for 10 clients with the largest payments + one position named "others" which represents rest of clients

View 5 Replies View Related

Modules & VBA :: Is There A Way To Shut Down A PC With VBA

Apr 10, 2015

I know it can be done with task scheduling for a set time. However, I am looking for a way whereby the changing the time to shut off is very quick and easy to do as it would be continually done at different times. I have searched Google high and low but to no avail. I was hoping that I could have some VBA run with the On Timer event. The shut down would have to be done while the computer was either streaming a video or playing a radio station.

One simple way I could do it would be to pull the battery from a laptop and then have it plugged into one of those plugs that you just wind back for 60 minutes or 2 hours etc. before they shut off the power. However, would doing that corrupt Windows 8.1?

View 5 Replies View Related

Modules & VBA :: Set Value To Variable Outside Sub?

Aug 26, 2014

If I set a variable inside of a subroutine, it is set to nothing upon the end of the sub. Can I set a variable outside a sub and set its value, so that you can use it within subs?

View 14 Replies View Related

Modules & VBA :: Export To XLS Instead Of TXT

Jul 10, 2013

I am making a database that will run the administrative part of a government run foreign teacher recruiting division.Running Office 2013 (and yes, it is overly bright), have used 2003,2007, 2010...I need to do mail merges, with lots of different sql's and templates. I have been using Albert Kallal's method and it works well.

However, some of my data is in THAI. And (I think) because this method exports to a .txt file first (.888) the data gets lost and shows as question marks.

Manual merge works fine.if I could export to xls in stead of .txt and use that as my merge source, that would work fine, but what part of the code would have to be changed.

Basically:
- export to xls in stead of the .888 file
- use the xls file as a datasource for the merge

View 1 Replies View Related

Modules & VBA :: Getting The Value From A Table

Apr 18, 2014

I've got a bit of a problem with determining the max value in the table. I have a table called "Functions" and a column: "Function_KSW". There are values as follows:

281A01
421A01
281A02
etc.

I want to get the max value of them but under the condition that first three chars are e.g 281 so the max function will take only max from a narrowed criterion. The chars are to be selected from combolist in a form. I have written something like this:

Code:
Private Sub Click1()
Dim max As String
max = DMax("Function_KSW", "Functions", "Function_KSW like " * 281 * "") // here 281 for the test's need
// should be: like " * [Forms]![Form1]![ListBox0]*"?

[Code]....

BTW. When I want to find the max by the SQL in the query and based on the value to sort in combolist in the form, sorting doesn't work as well. When the dirtect value (here 281) is written in the code it is working. Seems that those ** stars unable to retrive the vaule from the combolist

View 9 Replies View Related

Modules & VBA :: Using Caption Instead Of Name?

Apr 22, 2015

I'm trying to customise the error message for Input Mask Violations, so that it references the control where the error has occured, rather than just being a generic error message.

I can make this work using the code below:

Private Sub Form_Error(DataErr As Integer, Response As Integer)
Const INPUTMASK_VIOLATION = 2279
If DataErr = INPUTMASK_VIOLATION Then
MsgBox "Please check that the information you have added in the " + Screen.ActiveControl.Name + " field is in the appropriate format."
Response = acDataErrContinue
End If
End Sub

BUT, all my field names are shortened e.g. Mobile Number = MobileNo, so I want to use the caption property instead. I assumed I could just change it to "Screen.ActiveControl.Caption". But this doesn't work at all!

View 5 Replies View Related

Modules & VBA :: Add Validation For Not Zero

Jul 24, 2014

I have the following that I found in a post on Keypress of a text field to limit the field to only numbers. This works great only I need to disallow the entry of zero.

If KeyAscii <> 8 Then ' Not Backspace (important for error correction)
If KeyAscii < 48 Or KeyAscii > 57 Then 'Not a number
Beep 'Let the user know they hit an illegal key
KeyAscii = 0 'Don't let the keystroke through
End If
End If

View 14 Replies View Related

Modules & VBA :: Using Mid In A String

May 1, 2014

I'm trying to get a value from a spreadsheet to import into my MS Access database. Currently I am trimming the spaces/carriage returns from it but need to strip some more data from the value.

Here is my code.

trimmed_department = Trim(Replace(new_department, vbCrLf, ""))

Example value being "123 Point 5 Finance and Accounting"

I want to use Mid (I think?) to remove the "123 Point 5" (it is always the same with no exceptions) but don't know how to use it as I don't know how to use multiple parameters within a string.

View 8 Replies View Related

Modules & VBA :: Insert Into Using Do While

Dec 4, 2013

I have two subforms: sf1 (Based on Table 1) and SF2 (Based on Table 2) in the first I have the fields and CODE QTY.

I need to insert into the second table, as many records as QTY. to enter a serial number for each unit of the item. For example:

TABLE 1
COD. QTY.
001 2
006 1

I must insert into Table 2
001
001
006

Dim num As Integer, contador As Integer
contador = 0
num = Forms![FacturasRec_NSF]![FacturasRec_Det_SF].Form![CANLFR].Value
Do While contador = num
Insertar
contador = contador + 1

[Code] ....

but I could not even.

View 6 Replies View Related

Modules & VBA :: How To Use Tempvars

May 15, 2014

How to use a tempvar in the following line :

Forms!ColdTemperatures![TempVars("Button1")].ForeColor = vbRed

What I am doing is on close of a form I want to change the colour of a button on another open form (the name of the button is held in the tempvar). But I cant get it to work...

View 14 Replies View Related

Modules & VBA :: Progress Bar In Do While

Aug 22, 2014

How can I do a progress in bar in a do while. I export contract and during the export i want to have a progress bar.

do while
msgbox "the export runs", progress bar
Loop

View 13 Replies View Related

Modules & VBA :: Using And / Or Within If Statement

Aug 2, 2013

I am having some issues trying to use both and & or in a If statement.

The code below is what I am trying to do and it is not working.

Code:

ElseIf (Len(Nz(Me.Associate_name, "")) = 0 And Me.Status <> "Expired") Or (Len(Nz(Me.Associate_name, "")) = 0 And Me.Status <> "No longer eligible") Then
MsgBox "Please enter Associate Name"
Me.Date_authorization_expires.SetFocus

I tried the code below and it works but as soon as a I enter the Or part it will not work.

ElseIf (Len(Nz(Me.Associate_name, "")) = 0 And Me.Status <> "Expired") Then
MsgBox "Please enter Associate Name"
Me.Date_authorization_expires.SetFocus

I am not sure where I am going wrong.

View 11 Replies View Related

Modules & VBA :: Cannot Go To Specified Record

Mar 6, 2014

I have the following code.

Code:
Dim ctl As Control

For Each ctl In Me
Me.Assigned = Me.Combo55
DoCmd.RefreshRecord
DoCmd.GotoRecord , , acNext
Next ctl

I keep getting an error that says cannot go to the specified record. How can I go about fixing this?

View 14 Replies View Related

Modules & VBA :: Wildcard In URL / Before And After

Feb 21, 2014

I'm trying to add a spreadsheet from a folder using wildcards by just looking for a number in the file name.

strPath = "C:Training"
strFile = strPath & "*" + "(ZZ131008)" + "*.xls"
DoCmd.TransferSpreadsheet acImport, , "Training1", strFile, , ""

I get a response saying it cannot find the file and it shows the * in the path it cannot find. How can I make it find the right file?There are more files in the folder and the (ZZ131008) defines that course, I'd like to reuse the code for the other courses too.

View 3 Replies View Related

Modules & VBA :: Most Often Value In A Field

Mar 2, 2014

How can i get the value that is used most common in one column of the table through vba code?

View 2 Replies View Related

Modules & VBA :: Sum Row Cells Value?

Sep 17, 2013

I'I need to randomly input values into row cells and when press enter key, it calculates the total value and show in another sheet. Example, in sheet1, I input random values in A1,C1,D1,Z1 and when I press enter key, it calculates the total value and appear in the first row cell, A1, of sheet2. All by VBA coding.

View 1 Replies View Related

Modules & VBA :: Put 0 Before The Number If It Is Less Than 10?

Aug 6, 2014

The following code copies data from Access table to Excelsheet1. But the thing is when it combines Type,Type1 and Type2 in the query then i want to put some condition as below:

if Type1 value is less than 10 then put 0 before Type value
if Type2 value is less than 10 then put 0 before Type1 value.

e.g Type=5, Type1=8, Type 2=19 then in the sheet1 it should show: 50819 but at the moment it shows 5819.

Code:
strsql = "Select CDate(Format(Scandate,""0000-00-00"")) As [Scan_Date],batchno,ScanBoxID,envelopes,cases,pages,Type & Type1 & Type2 from Table1 where (Type=2 or type=3) and scandate =" & J
rs.Open strsql, cn
Set ws = ThisWorkbook.Worksheets("Sheet1")
ws.Range("b8:I1000").Clear
ws.Cells(8, "B").CopyFromRecordset rs
ws.Cells(2, "G").Value = J
rs.Close

View 3 Replies View Related

Modules & VBA :: Import A CSV

Dec 9, 2013

I'm trying to import a CSV. When I open the CSV, some of the values have decimal places (e.g. the dollar charge is $342.25). When the file is imported to a table, it shows up as $342.00. I import this file every month, and never have a problem. For some reason this month, the file is importing only the whole number.

View 9 Replies View Related







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