agrothe 26 Junior Poster

To build on what the previous two posters said, you basically want to use your textbox as a variable.

So in the on_click code of your command button put something like:

Form1.recordsource = "select * from tablename where columname like '" & textbox1.value & "*';"
form1.requery

This will change the underlying record source of your form based on the text in your text box.

You can actually get a nice filter going with several options via combo boxes and list boxes using this technique. I've got a working sample somewhere of about 6 options to filter a query based form somewhere.

Don't forget to check to make sure there is actually a value in the text box first.

agrothe 26 Junior Poster

I must be getting soft....

How the heck to do I programmatically add new rows to a datagrid / flexgrid or whatever grid using VBA?

It's not bound to anything and I'm trying to add data on the fly. Any ideas?

agrothe 26 Junior Poster

Hi,
my ajax will only work if you insert the www in firefox. IE is fine either way.

Any ideas?

Well, I fixed it with this javascript anyway....

var a = document.location.href;
    if (a.substr(7,3) == "www") {
        tmp = "http://www.domain.ca";
    }else{
        tmp = "http://domain.ca";
    }

Basically whatever url I passed in xmlHttp.open("GET",urlstr,true) had to match the actual url in the address bar.

agrothe 26 Junior Poster

Hi,
at url http://lowellbonnell.ca/index.php?view=Markets my ajax will only work if you insert the www in firefox. IE is fine either way.

Any ideas?

agrothe 26 Junior Poster

I've developed a quote/order database in access 2003 for a customer, so this is primarily a VBA solution, but I'm mostly after theory today so vba or vb is irrelavant.

I have of course normalized tables containing historical and current orders.

Right now, I have a reminder type form that shows all completed orders from a year ago from current date + 30 days.

So if today is Feb 1st 2007, it shows all orders from feb 1st 2006 to march 2 2006 and allows the operator to click a button and have an email reminder sent to the customer asking if they'd like to reorder. Easy enough and done.

HOWEVER, suppose the customer doesn't order on a yearly basis? Maybe it's a 6 month order cycle or 7 month, or something non-even, like every may, oct and dec?

What I've tried is adding up all the months that a customer orders, so in the past 7 years, ignoring the year part of the dates, which month did the customer most often order?

Seams to give some decent results but I'd like to more accurate figures. Any suggestions?

agrothe 26 Junior Poster

Voila! Easy recovery Did it. Thanks a ton, Agrothe, and all you other kind Daniweb community users who offered suggestions... Deeply appreciate your help.

Jimwall80

I'm glad you got your work back. I've been there, done that, burnt the tshirt....

agrothe 26 Junior Poster

You should use:
for ($i = 0; $i <= 28; $i++) ......
since the keys of your $random_array are from 0 to 28

True enough:

although instead of :
$random_array = array_rand($strAd, 29);

I'm using:
shuffle($strAd);

As array_rand seam like it can give me duplicates of the same original index whereas shuffle uses all of the original indexes but simply shuffles them.

You really got me on the right track though, Thanks.

agrothe 26 Junior Poster

Your best off finding a dedicated VBA forum, as Visual Basic 6 and Visual Basic for Applications are two different things. Similar, but VBA is quite limited as I found out when I started VBA programming in Access and Excel.

Best way to learn VBA IMO is to drop some controls via wizard on a worksheet and examine the code behind it.

agrothe 26 Junior Poster

There is a program called EasyRecover which I have used in the past. It's really good. However, if in restoring you computer you wrote over the areas which your program was on your hard drive, its probably gone for good. Try running the recover software on your thumb drive too.

agrothe 26 Junior Poster

$random_array = array_rand($sAdText, 3);

Thanks johny_d, thats awesome.

Here is my final code!

<?php
$strAd = array();
$strAd[0] = "html with qoutes escaped...";
$strAd[1] = "html with qoutes escaped...";
.......
$strAd[28] = "html with qoutes escaped...";

srand((float) microtime() * 10000000);
$random_array = array_rand($strAd, 29);

echo "<table cellpadding=\"0\" cellspacing=\"0\">";

for ($i = 1; $i <= 29; $i++) {
    echo $random_array[$i];
}

echo "</table>";
?>
agrothe 26 Junior Poster

Hey,

I've taken over a php based website from another developer (ugh!)...

The website uses two include files to display ads down both sides of the page. Now the client wants these ads to display in Random positions....

So, Its easy enough to take the ad text and place it in variables,

$sAdText[0] = '<tr><tr>link text and ad image here</td></tr>';
$sAdText[1] = '<tr><tr>link text and ad image here</td></tr>';
$sAdText[2] = '<tr><tr>link text and ad image here</td></tr>';

How would I go about getting these to display randomly? I can reverse them with a loop I guess, but I'd like a more random solution than that if possible.

agrothe 26 Junior Poster

Corba is hardly ever used anymore, been completely superceded by SOAP.

From Wikipedia:
SOAP is a protocol for exchanging XML-based messages over computer networks, normally using HTTP/HTTPS. SOAP forms the foundation layer of the Web services stack, providing a basic messaging framework that more abstract layers can build on.

Looks like I need to do some reading on this, as this is very similar to what I'm trying to accomplish.

Thanks jwenting, and by the way, do you have a life outside these forums? lol :)

agrothe 26 Junior Poster

I downloaded JCreater the other day and deleted it 50 seconds later. I'm no pro at java but i'm not an absolute beginner either. I've settled on use Notepad++ to edit and command line to compile and run. A simple bat file takes care of compiling and running for me quite easily. I've got Netbeans installed for a quick gui build, which I then copy and paste into an existing project, or just add the gui as a class.

All the IDEs i've used so far create so much junk code it's unbelievable.

agrothe 26 Junior Poster

The only disadvantage (which you'd also have if you're serialising objects yourself) is that it won't be portable to other platforms without serious effort.
Only platform agnostic systems like SOAP and Corba provide for that out of the box.

So what your saying is, if I want maximum portability and to run effortlessly on any platform, I should just stick with sockets and continue parsing strings?

I guess I could just brake an object down to a delimited string, transmit through socket, and then rebuild on the other end.... Or is Corba worth learning for this wanted (read: not needed) functionality?

agrothe 26 Junior Poster

Thanks, I'll look more into wrapping the ObjectOutputStream. RMI and CORBA sound great by SUNs tutorials, but I think for something simple as what I'm trying to accomplish they will add too much baggage and just complicate things needless. I'd rather the lower amount of overhead possible.

agrothe 26 Junior Poster

I've revived an old java project I did in college. Basic chat type program like ICQ which stores offline messages and users in a database etc, etc.

I've recently switched the database from Access to MySQL and am considering some other alterations.

I've been reading a bit on RMI. I guess what I'd like to know is can I pass more than just string across the sockets? The program uses a BufferedReader and I just built it to pass delimited strings which both the client and server parsed on either end.

I'm not sure if java supports user-defined-types either, but I guess thats basically what I'd like to pass back and forth just to make things easier.

agrothe 26 Junior Poster

I've added a vbscript to an asp page in order to print without showing the print dialog box.

Everything works fine when you first load the page, but when you try and navigate away from the page, you get the "A script on this page has caused internet explorer to run slowly" error.

this code was added in the <head> tags,

<%
  Sub cmdClickMe_OnClick
          WBControl.ExecWB 6,2,3
          set WBControl = nothing
  End Sub
%>

and this on the page body,

<object id="WBControl" width="0" height="0" classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></object>
<img src="images/print.gif" NAME="cmdClickMe" VALUE="Click> Me"
agrothe 26 Junior Poster

Thanks for the suggestions! Isn't Hibernate an implementation of RMI?? anyway....

Hypothetically speaking, if an application need to scale from 50 to 500,000 users(disregarding hardware issues) would all three tiers really be necessary? Could we just go with:

many clients <----> Server <----> Database ???

Although I guess the 3rd Tier allows for better control of say, connecting to different types of databases though...

And although yes, Hibernate/RMI seams like the way to go, I think all would agree setting up a simple client server from scratch or playing with a code sample is probably better starting out to learn the bare bones first. At least I find that jumping into something more complex without first seeing the different parts in action just complicates the matter.

agrothe 26 Junior Poster

I'm wondering what thoughts people have on the best way to implement a 3 tier application.

I'm playing with the idea of multiple clients <---> server <----> database server <----> mysql database.

I'm not sure if the database server is a necessary step though.

My previous foray into java network progamming just used sockets, but I've read that RMI(?) is a better approach? What think ye? Does anyone know of a basic 3 tier code sample I can get my feet wet with?

agrothe 26 Junior Poster

I have a Access 2003 database which has a table we'll call orders.
There are 10 other tables linked to orders through Order_ID.

I'd like to be able to create a duplicate of a record and all the associated records in the linked tables.

I've read it possible with an append query, but I'm wondering if there is a way to filter a recordset and then append the recordset back to the original table. 11 recordsets, 11 filters and 11 appends as opposed to 1 huge dirty query which would be harder to debug in my opinion but i'm more than open to advice and options here.

agrothe 26 Junior Poster

I'm trying to filter a subform based on combobox selection and getting a runtime error '424' - object required.

I downloaded the code from http://www.techonthenet.com/access/forms/filter_form.php and verified that it works in the provided sample database.

I copied the example and I'm getting the runtime error. I tried copying everything to a new form in case of form corruption with no results.

I've checked all the names of forms and controls as well.

Option Compare Database
Const LSQL = "SELECT [Order].[Id], [Order].[SellingPrice], [Client].[CompanyName], [Job].[TakenBy], [Job].[Referral], [Order].[CompletionDate], [Order].[Total_Labour], [Order].[Total_Material] FROM (([Client] INNER JOIN [Order] ON [Client].[CustomerID] =[Order].[CustId]) INNER JOIN [Job] ON [Order].[Id] =[Job].[Order_Id])"
Dim SQL As String

Sub SetFilter()

    SQL = LSQL & " where CustomerID = '" & cboEmp.Value & "'"
    
    form_frmReportSub.RecordSource = SQL 'ERROR IS HERE

End Sub

Private Sub cboEmp_AfterUpdate()
    
    'Call subroutine to set filter based on selected CustomerID
    SetFilter
    
End Sub

The code breaks at form_frmReportSub.RecordSource = SQL as noted above.

agrothe 26 Junior Poster

call me Andrew, please, and thanks.

agrothe 26 Junior Poster

Once you figure out the loops, i would kindly suggest that you initilize your random function before calling it.

I'm sure one of the expert residents (nudge at comatose) can explain a lot more as i'm not 100% sure how this is done in VB, but each time you start your exe, the first set of numbers are always the same, second set the same, etc.

Just some food for thought.

agrothe 26 Junior Poster

What if you always add a set number (say 5) blank rows to your database table. There would always be 5 (new) rows which a user could edit.

agrothe 26 Junior Poster

I'm new to VB so my question is probably very simple. anyway here it is..

I want to make a side bar showing one form that is like a sidebar in a web page such as on the left side of the MDI form. Which holds the programs main functions .. Then once a button is pressed on that form, I want it to show the form that performs that action in the right pane. Without just popping up . I've tried setting the left property of the window popping up and the dimensions larger than the screen but it doesn't work , and when I set it to maximize on start, then it covers the left frame.

Any help appreciated.

Sound like you need to add an image control to your MDI form. It will snap to either side or to top or bottom. Then you can add buttons, combo's and other controls to the image control. Or was it a picture control? Image or picture, only one will work, but that sounds like your solution.

Also, forms will automatically see the edge of your image control as the edge of the mdi form, so scroll bars will appear properly if the form goes behind the image control so users and scroll over to see it.

Comatose commented: Nice Job On This One +5
jonc commented: Superb, I was looking for an idea on making a sidebar - that's cleared it all up. Thanks! +2
agrothe 26 Junior Poster

Would anyone know how, if it's possible, to pass a user defined type through a network connection say using winsock?

For example:

type tExpl
      name as string
      address as string
      phone as string
end type
 
dim myExpl as tExpl
 
winsock1.send myExpl

As far as i know, winsock only sends text or raw data, anyone know if this is possible?

agrothe 26 Junior Poster

I don't see the problem.... VB is reading data from the serial port right? So should it matter if the form's .visible property is true or false?

I wonder is it possible the application doesn't have a proper hook on the serial port? Is a third party control being used or windows API?

agrothe 26 Junior Poster

I havn't done Oracle since ver. 7, but I know most mainstream databases have an SQL dump or export ability which will allow you to export table structures and data. You may need a third party database explorer to do it, but it's always possible.

I use EMS SQL Manager 2005 Lite for MySQL for directly manipulating my web MySQL databases. Try something specific to Oracle, although I would be supprised if that functionality isn't already built in.

agrothe 26 Junior Poster

how do i add items to a combobox from a listbox that is in another form??

You can reference the listbox directly using:

combobox.additem frmOtherfrm.listbox1.index(frmOtherfrm.listbox1.listindex)

This code will grab the currently selected item, and will cause an error if there is no selected item. You probably want to cycle through all the items, or search for a particle one based on criterea though.

agrothe 26 Junior Poster

how do i add the numbers in a listbox and display it in another textbox?

Create new project, add list1 and txtText1 to the form1 and paste:

Option Explicit

Private Sub Form_Load()
    Dim x As Integer
    Dim inx As Integer 'counter
    
    List1.AddItem "1"
    List1.AddItem "2"
    
    For inx = 0 To List1.ListCount - 1
        x = x + CInt(List1.List(inx))
    Next
    txtText1.Text = x
    
End Sub
agrothe 26 Junior Poster

Seams like the Else never fires. Try something like this. . . and step through the program when purposely clicking on a wrong letter to see why the else never gets executed.

dim bGoodGuess as boolean

For Counter = 1 To 5
    If letterguess = letteranswer(Counter) Then
        lblAnswer(Counter).Visible = True
bgoodguess = true
    end if
next
    
if not bGoodGuess then
deathcounter = deathcounter + 1
Select Case deathcounter
    Case deathcounter = 1
        Line1.Visible = True
    Case deathcounter = 2
        Line2.Visible = True
    Case deathcounter = 3
        Line3.Visible = True
    Case deathcounter = 4
        shpHead.Visible = True
    Case deathcounter = 5
        shpTorso.Visible = True
    Case deathcounter = 6
        shpRarm.Visible = True
    Case deathcounter = 7
        shpLarm.Visible = True
    Case deathcounter = 8
        shpRleg.Visible = True
    Case deathcounter = 9
        shpLleg.Visible = True
End Select
    
    
    End If
agrothe 26 Junior Poster

yes it is! any shape you want, how many form you want....

look here:
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=50793&lngWId=1

or here:
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=12991&lngWId=1&txtForceRefresh=627200610312635313


it's easy!

Neither of those projects have references to DirectX, so don't waiste your time trying them. They deal with custom form shapes.

Here are some tutorials on programming with DirectDraw.
http://francis.dupont.free.fr/coindev/english/

Comatose commented: Thanks. +3
agrothe 26 Junior Poster

hmmm . . . thats a neat technique, though for the record, if you have Option Explicit in your module you will need to Dim Xfrm as Form in that procedure.

agrothe 26 Junior Poster

Sure.

Create a new project, add an MDI form and 2 or more MDI Child forms.

in the MDI Form code window paste:

Private Sub MDIForm_Click()
MsgBox Me.ActiveForm.Caption
End Sub

Click on the MDI form to see which child form is currently active. The .ActiveForm property gives you complete access to the current active MDI Child. For example: .hide .show .caption .width .height etc...

agrothe 26 Junior Poster

Sorry to report that Agrothe's code did not work. Merlin never appears to say the time.

<cut code and explanation from here seeing as joe935 posted the solution himself seconds before I hit the post button!:o>

Good job joe!

agrothe 26 Junior Poster

The Timer Control is a control that makes a certain set of code execute at a given interval. It gets set in milliseconds, so 1000 is 1 second in the interval. The purpose of a loop is to execute a given set a code either a given number of times, or until a specific condition forces a change that will stop the loop.... a timer control just simply executes a set of instructions every so often. Also, with a timer control, your app is free to have other events happen, in between (or even during) timer events.... which reduces your need to use doevents, and also saves on Processor Time.

Yeah, what he said! :cheesy:

agrothe 26 Junior Poster

Declare your variables at the form level, if you declare in the procedural level, they get reset each time the sub or function runs.

agrothe 26 Junior Poster

Yup, that's write... do me a favor and toss in some code tags ;)

write or right?? LOL code tags it is . . .

agrothe 26 Junior Poster

I've rearrainged your code a little although you may still need to adjust a thing or two to make it work.

Basically, you don't need a continous loop in form_load, the timer takes care of that. Try This:

Private Sub Form_Load()
 On Error Resume Next
 CenterForm
 LoadAgent "merlin"
 theAgent.Speak "Hello"
 theAgent.Hide

Timer1.Interval = 60000
Timer1.Enabled = True
   
End Sub

Private Sub Timer1_Timer()
 Mytime = Time
 Myhour = Hour(Mytime)
 Myminute = Minute(Mytime)
 Mysecond = Second(Mytime)
 Debug.Print Mysecond, Myminute
 If Mysecond = 0 Then
     If Myminute = 15 Or Myminute = 30 Or Myminute = 45 Or Myminute = 1 Then saytime("The time is " & Myhour & ":" & Myminute & ".")
 End If
End Sub

Private Sub sayTime(txt as string)
 theAgent.Show
 theAgent.Play "announce"
 theAgent.Speak txt
 theAgent.Play "announcereturn"
  theAgent.Hide
End Sub
agrothe 26 Junior Poster

Use a timer control instead of a loop. This should all but eliminate your CUP Usage.

Just a a quick test, I created a new project, set form1 to open form2 every 2 seconds via timer control, and put a timer on form2 which unloaded from memory every 1 second.

I coun't get anymore than 15% CPU usage with avg around 7%. With the timer set to 150000 on form1, CPU usage was avg 2%, max 5% when counting down and max 7% when actually loading and unload form2.

Of course, CPU usage will vary depending on what system specs you have.

Mine is Athlon XP 3000+ (2.17 GHz) and 768MB RAM.

agrothe 26 Junior Poster

Sounds like you need to take code out of the same table as category, might help make the system more usable.

agrothe 26 Junior Poster
Do Until deathcounter = 9
     DeathCount
Loop

This seams to be where it locks up. You don't increment deathcounter anywhere in the loop or in the deathCount sub.

Look at your code and decide if you really need this function call in a loop.

agrothe 26 Junior Poster

I think you have to manipulate the printer object directly.....

This is correct. Use:

Printer.Orientation = 2
Form1.PrintForm

1 for Portrait and 2 for Landscape.

agrothe 26 Junior Poster

Why not use a control array and a counter? Every time someone guesses wrong do:

count = count + 1

if NOT controlarray(count).visible and NOT count > Ubound(controlarray()) then
controlarray(count).visible = true
end if


Thats how I did a hangman game back in 98 on my brother's laptop while driving on family vacation from Winnipeg to Minniapolis :)

agrothe 26 Junior Poster

This may be a little off topic, but a cool project would be to take one of those chatterbots and modify it to take speech and speak in return ;)

agrothe 26 Junior Poster

;) why not?

I'll need that in writing. . .

agrothe 26 Junior Poster

you can find a full tutorial and code samples at

http://www.microsoft.com/msagent/dev/default.asp

agrothe 26 Junior Poster

Soooo......

You Want Someone To Do Your Homework For You?

If i write the script, can i have his degree??

agrothe 26 Junior Poster

I'm sure it's just something simple, like maybe try refreshing the report after you set the label value? If your really desperate, create a table linked to the table which your report is pulling from to hold different title values and update the table prior to calling your report. Base your report off a query which then pulls your original data plus the newly updated title from the related table.

agrothe 26 Junior Poster

How would i make visual basick remember selections from other forms so it will excute the disired outcome at the end of my process.

It also depends on what you mean by 'process'. If you trying to create a wizard type application, save the form selections in variables for easy reference at the end of the process. If your 'process' spans multiple application instances then, as comatose said, you'll need to use files or what not. And you could use a database, but thats a whole different discussion. . . .