Help With Recordcount Command

Jul 14, 2006

I am trying to count how many records has a table with a special value (SolicitaçãoID.Text) but I keep getting error:
Compile Erro:
User-Defined not defined

And it goes to this line: Dim db As DAO.Database

This is the command:

Private Sub CmdAmostra_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim intResult As Integer
Dim strSQL As String

Set db = CurrentDb
SolicitaçãoID.SetFocus
strSQL = "SELECT COUNT (*) As RecordCount FROM Protocolo_O where SolicitaçãoID=" & SolicitaçãoID.Text
Set rs = db.OpenRecordset(strSQL, dbOpenSnapshot)

intResult = rs("RecordCount")

MsgBox intResult

Amostras.SetFocus
Amostras.Text = intResult

rs.Close
db.Close

End Sub

Well i have no clue what that error means and why.
Thanks for the Help
Art

View Replies


ADVERTISEMENT

RecordCount Please Help! Im Stuck

Oct 6, 2006

Thanks for looking at my post. What I have done is this, i have built a custom search form for my access database. What i need is a textbox that shows how many records will show up if the user clicks generate form.. I want this textbox to update every time the person changes his search criteria. For example

the person wants to search by address, by typing in

Gold into the address textbox the recordcount textbox would show the user if he were to press generate form he would get

1200 records

now if he changes the address to
GoldStone -- the recordcount textbox would then update to show only

14 records would be shown if he/she generated the form...
Here is my current code

***********
Set db = CurrentDb
Set qdf = db.QueryDefs("MainDB_Search")

For Each prm In qdf.Parameters
prm.Value = Eval(prm.Name)
Next prm

Set rs = qdf.OpenRecordset(dbOpenDynaset)
rsCount = rs.RecordCount

MsgBox (rsCount)
txtGenerateReport.Value = rsCount

************
Now the problem with this code is that it works the first time the user types in search criteria, however when he/she tries to change it from Gold to Goldstone -- nothing happens, it runs the code above and returns 1200 records instead of the correct 14...

Please help :)

Thanks

Jason

View 4 Replies View Related

Subform Recordcount Problem

Aug 25, 2006

I have several bound subforms whose recordsources are based on querydefs...

I use the following code in the OnCurrent event of the main form to count the number of records on a subform,

Me.mysubformname.Form.RecordsetClone.RecordCount

but for some reason, one particular subform won't give me the correct count... the only difference I can see between the problem subform and the others is that it is populated by a union query... any reason why that would be causing the problem? Any other thoughts?

Thanks in advance,
Scott

View 3 Replies View Related

RecordCount Problems With ADODB 2.6

Feb 28, 2005

The company I work for remains on the 2.6 version of the various MDAC components. Unfortunately, upgrading is not an option that I can control. So....

When I open a recordset which DOES contain records, I often return a RecordCount of -1. EOF is false, so that is working, and I am able to use that to get around part of my problem. Where I need the count after iterating through the recordset, I am able to use an iCounter variable to get that. I have tried using MoveLast, MoveFirst, etc. before calling for RecordCount, but that does not help.

In many instances having the count BEFORE going through the recordset would be very helpful. Has anyone else ever encountered this problem? Anyone devise a workaround?

Thanks in advance for any help!

John

View 3 Replies View Related

Curious On Rich's Recordcount Advise

Nov 4, 2005

Rich helped Latex88 a little further down and the advise given was:

"=Count(*) in the control source of a textbox in the subform footer will do it, no vba is needed"

I tried this out out on a few of my subforms and it worked on all but one. The recordsource of the one that it does not work on is based on a query. When I changed the recordsource to a table then the recordcount works.

Curious as to why and is there a work around?

Thanks a head of time,
Shane

View 9 Replies View Related

Queries :: DAO RecordCount Versus Count Query

May 21, 2013

For small tables (<10,000 rows), which technique is faster, more efficient ?

View 11 Replies View Related

Forms :: Copying Command Button Appearance Properties To Other Command Buttons

Dec 17, 2013

I am rewriting an old Access 2003 database in Access 2010. When creating new command buttons, the current theme gives them a default appearance. I need to apply this appearance to old command buttons. I know there is a way to select the default button and apply its properties to others quickly. I have done it before but didn't write the process down .

View 2 Replies View Related

Command

Sep 18, 2006

Hi,

I have a question,

I made a Macros called AutoExec to run "beginning" Function

Function beginning()
If len(Command)>0 then
....................
End if
End Function

But, it has "compile error: Can't find project or library"

Why?
What's wrong with it?
Thanks.

View 2 Replies View Related

Need Help!! With Command..

Feb 28, 2006

hi,

i need serious help with my access project...

im designing a database for videoshop for loans in access. i have got my movies and loans tables (along with others) and have got them as a one to many (loans to movies) and have got Rental ID as Primary key in Loans table and got that linked to Rental ID# in movies table.

i want some sort of command in the loans form so that when a customer loans out a movie it will update the movies table (rented out field).

the fields that i have got in the loans table are:

Rental ID
Customer ID#
Movie Rented Out
Date Rented Out
Other Rental Details
Rental Duration
Daily Fine Rate

the fields in the movies table are:

Movie Title
Movie Quantity
Movie Description
Genres
Rating
Director
Popularity
Rented Out
In Stock
Supplier ID#
Rental ID#
Stores ID#


if anyone whos reading this knows how i can do this then it will be highly appreciated if u replied to this thread.

thankssssssssssssssssss.....

adeel.

View 1 Replies View Related

Command Button To Set Value

Apr 20, 2006

I have been working on this for awhile, and can't figure it out for the life of me!

I have a form set up with a drop down box that lets me pick from values from a table based off of the Primary Key of that table (Row Source = SELECT Order.OrderID, Order.OrderName from Order). I have a button on the form that I want to set a value (Closed) from the table entry based off of the order selected.

Pseudo code would go something like this.

Closed.Value = True Where Table.Order.OrderID = SelectedOrderID



Table.Order is a Table Named Order (obviously)
Closed is a yes/no field in my Order table
OrderID is the primarykey of the table Order
SelectedOrderID is the drop down box.

Any help would be greatly appreciated!

View 3 Replies View Related

Command Button?

Apr 26, 2005

I, unfortunately, have been singled out as the Access guru in my work area. We have 223 people and the Information Manager has tasked me to modify a database he "found" to be able to track a number of things, but most important to him: performance reports.

I have posted the sample of what I currently have. What is being asked of me is a way in which to have a button or by double-clicking a block where a date would go for all other dates on the form to become non-visible while the current date stored in the computer the database is being worked from be entered in the block where the button or double-click happened. All this links to a report for the IM to be able to track what performace reports are out, and when they are due back to his section. He also wants me to be able to show which are overdue and where they are at. I am not sure if it is at all possible, but with me having spend most of last week purusing the articles on Access here, I know now that nothing is implausible if you happen to go about it the right way.

Since I have read the rules on posting, here is what I have done. I searched the forum for command button and got a lot of really cool ideas to use elsewhere in the database. I looked up the help in the program itself for command button, and got some good information on how a command button works, but I cannot make it put a date into a block. I can enter the date in any block that is a date format, but then I have dates in every block. He only wants to see the most current date in any of the blocks.

Any assistance at this point would be appreciated. If I have missed something in another thread, I apologise in advance.

View 11 Replies View Related

Command Button %

Apr 28, 2005

how can i assign a formula to a command button?

also can anyone give me specific advice about calucalating the % of check boxes ticked across multiple records.

thanks in advance

View 4 Replies View Related

Command Button

May 25, 2005

A couple of weeks ago I asked the question of how to send a single record from one table to another (Archive table) using a command button. I got a response. I have had time to work with this a little. My problem is I keep getting a error message "Run-time error '3075'; Syntax error (missing operator) in Query expression "[New ID]='. I wanted to mention that the archive table has an "archive ID" field as well as "New ID" that links the tables. I have the following code. Please help with this if possible.

" Private Sub Command667_Click()
' Save the main record if it has not been saved.
If Me.Dirty Then
DoCmd.RunCommand acCmdSave
Me.Recalc
End If

If MsgBox("Do you want to archive this record?", vbYesNo) = vbYes Then
Dim SQL As String

' Move main record to Grants Activity Archive.
SQL = "Insert into [Grants Activity Archive]" & _
" select * from [Grants] where [New ID]=" '" & Me.ID & "'"
CurrentDb.Execute SQL
Me.Recalc
End If

End Sub "

The error seems to refer to the & Me.ID section. I have tried putting Me.New ID and also Me.Archive ID. The Grants Activity Archives is the subform where I want the record to go. This subform is set up like a form with many fields so it is a lot of work to type the main record from the Grants table to the Grants Activity Archive table every time you want to archive a record. I hope that makes sense.

View 4 Replies View Related

Find Command

Mar 7, 2006

I have a find command button that appears to call the find and replace message box. It should be a search for anything in my query. The code behind the button looks like the find and replace message box in the office suite. I believe I am trying to create a message box where you add an entry and it searches then lauches a subform with my entries.

When I checked the button it had the following code:
Private Sub cmdFind_Click()
On Error GoTo Err_cmdFind_Click

Screen.PreviousControl.SetFocus
DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70

Exit_cmdFind_Click:
Exit Sub

Err_cmdFind_Click:
MsgBox Err.Description
Resume Exit_cmdFind_Click

End Sub

I read a few of the lookup queries but they only give me a drop down. Is there some way to customize the box comes up without altering all of Office or do I just sound lost.

View 1 Replies View Related

Command Buttons

Mar 24, 2006

I am a newbie at Access and I am currently learning it for my job...I have a database going and I am wanting to do two things and I can not figure it out for the life of me.

Little background, the database I made is a continuous form. I am wanting a command button that when pushed will put it in data entry mode, and when pressed again will put back in a 'view all' state. I know it is a simple If Then, but I don't know VBA very well =

Other thing, is I wanting to be able have button that when pressed will output to an excel sheet, right now I have it when it is pressed it asks me what kind of format I want outputted, and I want it automated to just go straight to excel.

Any help would be appreciated, thanks.

View 3 Replies View Related

Sql Command Or Condition

Jun 11, 2006

hi i was wondering if anyone can tell me a condition or a command in which a user will be able to enter only 6 digit number. like 123456. if he tries to enter 234 the database should not accept. is this possible also? any help would be great.
Thanks

View 14 Replies View Related

DDEInitiate Command

May 18, 2007

Hi there,

In one of my access application one form is getting data from some other server.
This below line of code is getting used.

Dnumber = CStr(Forms![Results Hit List].Form![RecordId]) + I
x = DDEInitiate("AEX", "ODBC")
DDEExecute x, Dnumber

Can some one please tell me how DDEInitiate is working here?
I mean AEX is the name of ODBC connection or what?

Thanks
Danny

View 4 Replies View Related

Command Buttons

May 18, 2007

How do I make the command buttons on my form actually do something, the only one that attempts to work is "DELETE RECORD" the others dont do anything at all

View 8 Replies View Related

How To Run It From Command Line?

Jul 20, 2007

I have a vba module call runme with this code

Option Compare Database
Sub makequery()
Dim db As DAO.Database
Dim qry As DAO.QueryDef
Dim rs As DAO.Recordset
Dim fld As DAO.Field


Dim XlApp As Excel.Application
Dim xlwb As Excel.Workbook
Dim xlws As Excel.worksheet
Dim xlrn As Excel.Range

Dim x As Integer


Set db = Access.CurrentDb
Set qry = db.QueryDefs("q1")
Set rs = qry.OpenRecordset

Set XlApp = New Excel.Application
XlApp.Visible = True
Set xlwb = XlApp.Workbooks.Add
Set xlws = xlwb.ActiveSheet

x = 1
For Each fld In rs.Fields
xlws.Cells(1, x).Value = fld.Name
x = x + 1
Next fld

Set xlrng = xlws.Cells(2, 1)
xlrng.CopyFromRecordset rs
xlws.Columns.AutoFit
rs.Close
qry.Close



qry.Close


End Sub


I can run it from vb eidit interface by hitting run.
How can I run it from command line?

I tried "msaccess.exe" "C:Documents and SettingsjzhuMy Documents est.mdb" /Excl /X "runme"
But it does not seems to work.

THX.
Jeff

View 4 Replies View Related

How Can I Use One Command Button Only?

Feb 26, 2008

Hi all

Can any one correct my attached program to make it works with one command button only please?

Using two buttons make conflict.

Any help will be highly appreciated.

Thank you

vbnt

View 9 Replies View Related

Command Button

Apr 7, 2006

Hi I can't seem to be able to find any option to open a table from the command button wizard how is this possible. Thanks

View 2 Replies View Related

Union All Command

Feb 18, 2006

How do I use the union all command to combine 3 queries together and create a new field. I am trying to create a search that will combine the names in 3 fields and let me select any of them and pull up the records that are associated with that person.
I have written a database for an apartment complex. I am trying to simpify the search capabilities. They have 3 types of tenants, listed as HT-Head Tenant, CT-Co-Tenant & CT2- Co-Tenant 2. These fields are in a data base with all the info that applies to each apartment. I would like to be able to search from one combo box any of these tenants and have the correct information come up. Some one told me to use 3 queries and the SQL Union all command to get the fields combined into one field. But I can't get that to work. I am kind of a rookie as I have taught myself to do this so I might not be doing something correct. I was also told by doing the above steps I could use the ID field at the bound field. But not sure How to accomplish that either.
Appreciate any help I can get.
Thanks

View 3 Replies View Related

Command Button

Apr 20, 2006

Hi,
How can I make command button on my DAP to use update query that I wrote? :confused:

View 3 Replies View Related

LEN Command In Access / Sql

Nov 1, 2006

I have the following sql statement:


SELECT [PhoenixInventory-FTP-1].[Mfg Name] AS Mfg, [PhoenixInventory-FTP-1].VendorID, [PhoenixInventory-FTP-1].[Part #] AS [Part#], [PhoenixInventory-FTP-1].ID AS PartID, [PhoenixInventory-FTP-1].OH AS OnHand, [PhoenixInventory-FTP-1].OO AS FacOnOrder, [PhoenixInventory-FTP-1].[90DayUsage], [PhoenixInventory-FTP-CustOO].CustOO, [PhoenixInventory-FTP-CustOO-90].CustOO AS CustOOWithin90Days
FROM ([PhoenixInventory-FTP-1] LEFT JOIN [PhoenixInventory-FTP-CustOO] ON [PhoenixInventory-FTP-1].ID = [PhoenixInventory-FTP-CustOO].ID) LEFT JOIN [PhoenixInventory-FTP-CustOO-90] ON [PhoenixInventory-FTP-1].ID = [PhoenixInventory-FTP-CustOO-90].ID;


I wish to take this query and only display the Part #'s with less than 8 characters. I am pretty sure I need to use the LEN function, but am not sure on how to do it. Any ideas?

View 1 Replies View Related

Command Button Looks...

Mar 2, 2005

Hi everyone,

This is perhaps a simple question for which I have not been able to find an answer to. I've been trying to create a form which contain command buttons, but the problem is that the look of these buttons are not similar to those found in Windows XP.

I know it’s purely cosmetic :cool: - but how do I make my buttons in Access 2003 to look like those on my Windows XP?

I've seen some samples here on these forums which have the 'XP' look. Any hints on how to do this would be greatly appreciated.

All the best,
Sab.

View 2 Replies View Related

Command Button

Mar 23, 2005

Hi
I have a option group with 6 command buttons. The trouble is when you select a button, the button stays selected, so if you want to select it again you have to select another butoon then go back to it (hope this makes sence!). Is ther a way to re-set the button so it returns to un-selected mode!!!!
Thanks in advance!

View 5 Replies View Related







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