help new to VBA, easy question
Author |
Message |
L. Pfitzmaie #1 / 13
|
 help new to VBA, easy question
I am using access97, I know I need a connection in the link criteria between the two feilds to link on but don't know what symbol or wording is needed to lin both lines...thanks On Error GoTo Err_opennextform_Click Dim stDocName As String Dim stLinkCriteria As String stDocName = "editc2pmod" stLinkCriteria = "[2UYK_part]=" & "'" & Me![2UYK_part] "[2UYK_SERIAL_NO]=" & "'" & Me![2UYK_SERIAL_NO] & "'" DoCmd.OpenForm stDocName, , , stLinkCriteria Exit_opennextform_Click: Exit Sub
|
Mon, 04 Nov 2002 03:00:00 GMT |
|
 |
Dirk Goldga #2 / 13
|
 help new to VBA, easy question
If both your fields are text fields (and don't contain the single-quote character "'") you are almost there: You might use this: stLinkCriteria = "[2UYK_part]='" & Me![2UYK_part] & _ "' AND [2UYK_SERIAL_NO]='" & Me![2UYK_SERIAL_NO] & "'" The above statement encloses each field value in single quotes and combines the two criteria with "AND". If both your fields are numeric, you would drop the quotes around the values and use this instead: stLinkCriteria = "[2UYK_part]=" & Me![2UYK_part] & _ " AND [2UYK_SERIAL_NO]=" & Me![2UYK_SERIAL_NO] -- Dirk Goldgar (remove NOSPAM from reply address)
Quote: > I am using access97, I know I need a connection in the link criteria between > the two feilds to link on but don't know what symbol or wording is needed to > lin both lines...thanks > On Error GoTo Err_opennextform_Click > Dim stDocName As String > Dim stLinkCriteria As String > stDocName = "editc2pmod" > stLinkCriteria = "[2UYK_part]=" & "'" & Me![2UYK_part] > "[2UYK_SERIAL_NO]=" & "'" & Me![2UYK_SERIAL_NO] & "'" > DoCmd.OpenForm stDocName, , , stLinkCriteria > Exit_opennextform_Click: > Exit Sub
|
Mon, 04 Nov 2002 03:00:00 GMT |
|
 |
L. Pfitzmaie #3 / 13
|
 help new to VBA, easy question
ok I did what you suggested and got this error Syntax error (missing operator) in Query expression '[2uyk-part]=An/yuk-43a[anuyk_serial_No]=00001029" now the data showing looks right but I don't understand what is wrong, what is it looking for? Is the underlying query something other than what is in this code? the form query? thanks sorry
|
Mon, 04 Nov 2002 03:00:00 GMT |
|
 |
L. Pfitzmaie #4 / 13
|
 help new to VBA, easy question
ok I did this and got this error Syntax error (missing operator) in query expression '[2uyk_part]=An/uyk-43a[2uyk_serial_no]=000001029" Does this mean in the code for the button or the underlying query code? Sorry this is all greek to me
|
Mon, 04 Nov 2002 03:00:00 GMT |
|
 |
Dirk Goldga #5 / 13
|
 help new to VBA, easy question
Well, one of us made a mistake ;-) That's plainly invalid syntax. It looks as though the field [2UYK_part] is text and the field [2UYK_SERIAL_NO] is numeric. If this is not right, let me know before trying what I'm about to suggest. It also looks as though you didn't copy exactly what I wrote before, but maybe I'm mistaken about that. At any rate, based on my current understanding, here is a variation on the previous attempt that should work: Dim strQuote As String strQuote = Chr$(34) stLinkCriteria = "([2UYK_part]=" & strQuote & Me![2UYK_part] & strQuote & _ ") AND ([2UYK_SERIAL_NO]=" & Me![2UYK_SERIAL_NO] & ")" If that doesn't work, please check the data types of the two fields in question and report them to me. -- Dirk Goldgar (remove NOSPAM from reply address)
Quote: > ok I did what you suggested and got this error > Syntax error (missing operator) in Query expression > '[2uyk-part]=An/yuk-43a[anuyk_serial_No]=00001029" > now the data showing looks right but I don't understand what is wrong, what > is it looking for? > Is the underlying query something other than what is in this code? the form > query? > thanks sorry
|
Mon, 04 Nov 2002 03:00:00 GMT |
|
 |
L. Pfitzmaie #6 / 13
|
 help new to VBA, easy question
ok I feel so dumb, I checked and both fields are text feilds but I am afraid I don't know exactly where to place the code you just gave me(newbie to all this code) I inserted it like this and got an error about canceling the action Private Sub opennextform_Click() On Error GoTo Err_opennextform_Click Dim stDocName As String Dim stLinkCriteria As String stDocName = "editc2pmod" Dim strQuote As String strQuote = Chr$(34) stLinkCriteria = "([2UYK_part]=" & strQuote & Me![2UYK_part] & strQuote & _ ") AND ([2UYK_SERIAL_NO]=" & Me![2UYK_SERIAL_NO] & ")" DoCmd.OpenForm stDocName, , , stLinkCriteria Exit_opennextform_Click: Exit Sub Err_opennextform_Click: MsgBox Err.Description Resume Exit_opennextform_Click End Sub thanks soooo much for looking at this
|
Mon, 04 Nov 2002 03:00:00 GMT |
|
 |
Dirk Goldga #7 / 13
|
 help new to VBA, easy question
You're putting it in the right place. I'm not sure why you got the exact error you did, but I suspect it was caused by the fact that, in my message, one of the lines got wrapped to a new line when I didn't intend it to. Also, if both fields are text, then my criteria string must be amended a bit further. Here's yet another version to try: stLinkCriteria = "([2UYK_part]=" & _ strQuote & Me![2UYK_part] & strQuote & _ ") AND ([2UYK_SERIAL_NO]=" & _ strQuote & Me![2UYK_SERIAL_NO] & strQuote & _ ")" The above statement should consist of exactly 5 lines, of which all but the last end with a "_", the line-continuation character. Try that and, if it doesn't work, please report the exact error message that you get. -- Dirk Goldgar (remove NOSPAM from reply address)
Quote: > ok I feel so dumb, I checked and both fields are text feilds but I am > afraid I don't know exactly where to place the code you just gave me(newbie > to all this code) > I inserted it like this and got an error about canceling the action > Private Sub opennextform_Click() > On Error GoTo Err_opennextform_Click > Dim stDocName As String > Dim stLinkCriteria As String > stDocName = "editc2pmod" > Dim strQuote As String > strQuote = Chr$(34) > stLinkCriteria = "([2UYK_part]=" & strQuote & Me![2UYK_part] & strQuote > & _ > ") AND ([2UYK_SERIAL_NO]=" & Me![2UYK_SERIAL_NO] & ")" > DoCmd.OpenForm stDocName, , , stLinkCriteria > Exit_opennextform_Click: > Exit Sub > Err_opennextform_Click: > MsgBox Err.Description > Resume Exit_opennextform_Click > End Sub > thanks soooo much for looking at this
|
Mon, 04 Nov 2002 03:00:00 GMT |
|
 |
L. Pfitzmaie #8 / 13
|
 help new to VBA, easy question
Dirk I don't know what you the code you gave me did to my DB IS COMPLETELY DOWN! I have a back up but the the file will not let me over write, delete or do anyhting! I have a lot of people to answer to, this is not good!!! The main menu will not come up an I am getting the startup menu code If I get this ever straightened out I don't know that I can trust the code give you...sorry for you time Quote:
>You're putting it in the right place. I'm not sure why you got the exact >error you did, but I suspect it was caused by the fact that, in my message, >one of the lines got wrapped to a new line when I didn't intend it to. >Also, if both fields are text, then my criteria string must be amended a bit >further. Here's yet another version to try: > stLinkCriteria = "([2UYK_part]=" & _ > strQuote & Me![2UYK_part] & strQuote & _ > ") AND ([2UYK_SERIAL_NO]=" & _ > strQuote & Me![2UYK_SERIAL_NO] & strQuote & _ > ")" >The above statement should consist of exactly 5 lines, of which all but the >last end with a "_", the line-continuation character. >Try that and, if it doesn't work, please report the exact error message that >you get. >-- >Dirk Goldgar >(remove NOSPAM from reply address)
>> ok I feel so dumb, I checked and both fields are text feilds but I am >> afraid I don't know exactly where to place the code you just gave >me(newbie >> to all this code) >> I inserted it like this and got an error about canceling the action >> Private Sub opennextform_Click() >> On Error GoTo Err_opennextform_Click >> Dim stDocName As String >> Dim stLinkCriteria As String >> stDocName = "editc2pmod" >> Dim strQuote As String >> strQuote = Chr$(34) >> stLinkCriteria = "([2UYK_part]=" & strQuote & Me![2UYK_part] & >strQuote >> & _ >> ") AND ([2UYK_SERIAL_NO]=" & Me![2UYK_SERIAL_NO] & ")" >> DoCmd.OpenForm stDocName, , , stLinkCriteria >> Exit_opennextform_Click: >> Exit Sub >> Err_opennextform_Click: >> MsgBox Err.Description >> Resume Exit_opennextform_Click >> End Sub >> thanks soooo much for looking at this
|
Mon, 04 Nov 2002 03:00:00 GMT |
|
 |
Sandra Daigl #9 / 13
|
 help new to VBA, easy question
Don't panic - from what I've seen of the code there's nothing there that could have done too much damage to your db. Sometimes just rebooting is all you need to do to get out of a crashing database. Is this form being used as your startup form? Just hold down the Shift key while you open Access and that will circumvent the problem while you fix the bad code. The worst case scenario is that you might need to compact/repair your db or decompile it. Trust me, I've crashed more databases than I care to admit and I've always managed to pull it out with very minor losses (if any) - and of course this is why most developers make frequent backups of their work in progress. I hope you have a backup! Dirk has stuck with you on this and I'm sure his intentions are as good as anyone of us that respond to questions in these Newsgroups. This is something that most of us do on our own time. You will find that rude responses are likely to cause your posts to be ignored or filtered. So for your own good, don't flame at anyone in these NGs. If you still want help post again but please be respectful of those who offer solutions to your problems. Sandra Daigle
Quote: > Dirk I don't know what you the code you gave me did to my DB IS COMPLETELY > DOWN! > I have a back up but the the file will not let me over write, delete or do > anyhting! I have a lot of people to answer to, this is not good!!! The main > menu will not come up an I am getting the startup menu code > If I get this ever straightened out I don't know that I can trust the code > give you...sorry for you time
> >You're putting it in the right place. I'm not sure why you got the exact > >error you did, but I suspect it was caused by the fact that, in my message, > >one of the lines got wrapped to a new line when I didn't intend it to. > >Also, if both fields are text, then my criteria string must be amended a > bit > >further. Here's yet another version to try: > > stLinkCriteria = "([2UYK_part]=" & _ > > strQuote & Me![2UYK_part] & strQuote & _ > > ") AND ([2UYK_SERIAL_NO]=" & _ > > strQuote & Me![2UYK_SERIAL_NO] & strQuote & _ > > ")" > >The above statement should consist of exactly 5 lines, of which all but the > >last end with a "_", the line-continuation character. > >Try that and, if it doesn't work, please report the exact error message > that > >you get. > >-- > >Dirk Goldgar > >(remove NOSPAM from reply address)
> >> ok I feel so dumb, I checked and both fields are text feilds but I am > >> afraid I don't know exactly where to place the code you just gave > >me(newbie > >> to all this code) > >> I inserted it like this and got an error about canceling the action > >> Private Sub opennextform_Click() > >> On Error GoTo Err_opennextform_Click > >> Dim stDocName As String > >> Dim stLinkCriteria As String > >> stDocName = "editc2pmod" > >> Dim strQuote As String > >> strQuote = Chr$(34) > >> stLinkCriteria = "([2UYK_part]=" & strQuote & Me![2UYK_part] & > >strQuote > >> & _ > >> ") AND ([2UYK_SERIAL_NO]=" & Me![2UYK_SERIAL_NO] & ")" > >> DoCmd.OpenForm stDocName, , , stLinkCriteria > >> Exit_opennextform_Click: > >> Exit Sub > >> Err_opennextform_Click: > >> MsgBox Err.Description > >> Resume Exit_opennextform_Click > >> End Sub > >> thanks soooo much for looking at this
|
Mon, 04 Nov 2002 03:00:00 GMT |
|
 |
Sandra Daigl #10 / 13
|
 help new to VBA, easy question
Don't panic - from what I've seen of the code there's nothing there that could have done too much damage to your db. Is this form being used as your startup form? Sometimes just rebooting is all you need to do. Just hold down the Shift key while you open Access and that will circumvent the problem while you fix the bad code. The worst case scenario is that you might need to compact/repair your db or decompile it. Trust me, I've crashed more databases than I care to admit and I've always managed to pull it out with very minor losses (if any) - and of course this is why most developers make frequent backups of their work in progress. I hope you have a backup! Dirk has stuck with you on this and I'm sure his intentions are as good as anyone of us that respond to questions in these Newsgroups. This is something that most of us do on our own time. You will find that rude responses are likely to cause your posts to be ignored or filtered. So for your own good, don't flame at anyone in these NGs. If you still want help post again but please be respectful of those who offer solutions to your problems. Sandra Daigle
Quote: > Dirk I don't know what you the code you gave me did to my DB IS COMPLETELY > DOWN! > I have a back up but the the file will not let me over write, delete or do > anyhting! I have a lot of people to answer to, this is not good!!! The main > menu will not come up an I am getting the startup menu code > If I get this ever straightened out I don't know that I can trust the code > give you...sorry for you time
> >You're putting it in the right place. I'm not sure why you got the exact > >error you did, but I suspect it was caused by the fact that, in my message, > >one of the lines got wrapped to a new line when I didn't intend it to. > >Also, if both fields are text, then my criteria string must be amended a > bit > >further. Here's yet another version to try: > > stLinkCriteria = "([2UYK_part]=" & _ > > strQuote & Me![2UYK_part] & strQuote & _ > > ") AND ([2UYK_SERIAL_NO]=" & _ > > strQuote & Me![2UYK_SERIAL_NO] & strQuote & _ > > ")" > >The above statement should consist of exactly 5 lines, of which all but the > >last end with a "_", the line-continuation character. > >Try that and, if it doesn't work, please report the exact error message > that > >you get. > >-- > >Dirk Goldgar > >(remove NOSPAM from reply address)
> >> ok I feel so dumb, I checked and both fields are text feilds but I am > >> afraid I don't know exactly where to place the code you just gave > >me(newbie > >> to all this code) > >> I inserted it like this and got an error about canceling the action > >> Private Sub opennextform_Click() > >> On Error GoTo Err_opennextform_Click > >> Dim stDocName As String > >> Dim stLinkCriteria As String > >> stDocName = "editc2pmod" > >> Dim strQuote As String > >> strQuote = Chr$(34) > >> stLinkCriteria = "([2UYK_part]=" & strQuote & Me![2UYK_part] & > >strQuote > >> & _ > >> ") AND ([2UYK_SERIAL_NO]=" & Me![2UYK_SERIAL_NO] & ")" > >> DoCmd.OpenForm stDocName, , , stLinkCriteria > >> Exit_opennextform_Click: > >> Exit Sub > >> Err_opennextform_Click: > >> MsgBox Err.Description > >> Resume Exit_opennextform_Click > >> End Sub > >> thanks soooo much for looking at this
|
Mon, 04 Nov 2002 03:00:00 GMT |
|
 |
Dirk Goldga #11 / 13
|
 help new to VBA, easy question
I don't claim to know everything, but I don't believe that any of the code we've been working on is *capable* of crashing your DB. Possibly existing problems in your database or a succession of failed operations have caused some of the errors you've been getting, and also caused something in the DB to be corrupted. Have you tried Sandra Daigle's suggestions? If so, what was the result? -- Dirk Goldgar (remove NOSPAM from reply address)
Quote: > Dirk I don't know what you the code you gave me did to my DB IS COMPLETELY > DOWN! > I have a back up but the the file will not let me over write, delete or do > anyhting! I have a lot of people to answer to, this is not good!!! The main > menu will not come up an I am getting the startup menu code > If I get this ever straightened out I don't know that I can trust the code > give you...sorry for you time
> >You're putting it in the right place. I'm not sure why you got the exact > >error you did, but I suspect it was caused by the fact that, in my message, > >one of the lines got wrapped to a new line when I didn't intend it to. > >Also, if both fields are text, then my criteria string must be amended a > bit > >further. Here's yet another version to try: > > stLinkCriteria = "([2UYK_part]=" & _ > > strQuote & Me![2UYK_part] & strQuote & _ > > ") AND ([2UYK_SERIAL_NO]=" & _ > > strQuote & Me![2UYK_SERIAL_NO] & strQuote & _ > > ")" > >The above statement should consist of exactly 5 lines, of which all but the > >last end with a "_", the line-continuation character. > >Try that and, if it doesn't work, please report the exact error message > that > >you get. > >-- > >Dirk Goldgar > >(remove NOSPAM from reply address)
> >> ok I feel so dumb, I checked and both fields are text feilds but I am > >> afraid I don't know exactly where to place the code you just gave > >me(newbie > >> to all this code) > >> I inserted it like this and got an error about canceling the action > >> Private Sub opennextform_Click() > >> On Error GoTo Err_opennextform_Click > >> Dim stDocName As String > >> Dim stLinkCriteria As String > >> stDocName = "editc2pmod" > >> Dim strQuote As String > >> strQuote = Chr$(34) > >> stLinkCriteria = "([2UYK_part]=" & strQuote & Me![2UYK_part] & > >strQuote > >> & _ > >> ") AND ([2UYK_SERIAL_NO]=" & Me![2UYK_SERIAL_NO] & ")" > >> DoCmd.OpenForm stDocName, , , stLinkCriteria > >> Exit_opennextform_Click: > >> Exit Sub > >> Err_opennextform_Click: > >> MsgBox Err.Description > >> Resume Exit_opennextform_Click > >> End Sub > >> thanks soooo much for looking at this
|
Tue, 05 Nov 2002 03:00:00 GMT |
|
 |
Dirk Goldga #12 / 13
|
 help new to VBA, easy question
(reposted because I don't see my original out there) I don't claim to know everything, but I don't believe that any of the code we've been working on is *capable* of crashing your DB. Possibly existing problems in your database or a succession of failed operations have caused some of the errors you've been getting, and also caused something in the DB to be corrupted. Have you tried Sandra Daigle's suggestions? If so, what was the result? -- Dirk Goldgar (remove NOSPAM from reply address)
Quote: > Dirk I don't know what you the code you gave me did to my DB IS COMPLETELY > DOWN! > I have a back up but the the file will not let me over write, delete or do > anyhting! I have a lot of people to answer to, this is not good!!! The main > menu will not come up an I am getting the startup menu code > If I get this ever straightened out I don't know that I can trust the code > give you...sorry for you time
> >You're putting it in the right place. I'm not sure why you got the exact > >error you did, but I suspect it was caused by the fact that, in my message, > >one of the lines got wrapped to a new line when I didn't intend it to. > >Also, if both fields are text, then my criteria string must be amended a > bit > >further. Here's yet another version to try: > > stLinkCriteria = "([2UYK_part]=" & _ > > strQuote & Me![2UYK_part] & strQuote & _ > > ") AND ([2UYK_SERIAL_NO]=" & _ > > strQuote & Me![2UYK_SERIAL_NO] & strQuote & _ > > ")" > >The above statement should consist of exactly 5 lines, of which all but the > >last end with a "_", the line-continuation character. > >Try that and, if it doesn't work, please report the exact error message > that > >you get. > >-- > >Dirk Goldgar > >(remove NOSPAM from reply address)
> >> ok I feel so dumb, I checked and both fields are text feilds but I am > >> afraid I don't know exactly where to place the code you just gave > >me(newbie > >> to all this code) > >> I inserted it like this and got an error about canceling the action > >> Private Sub opennextform_Click() > >> On Error GoTo Err_opennextform_Click > >> Dim stDocName As String > >> Dim stLinkCriteria As String > >> stDocName = "editc2pmod" > >> Dim strQuote As String > >> strQuote = Chr$(34) > >> stLinkCriteria = "([2UYK_part]=" & strQuote & Me![2UYK_part] & > >strQuote > >> & _ > >> ") AND ([2UYK_SERIAL_NO]=" & Me![2UYK_SERIAL_NO] & ")" > >> DoCmd.OpenForm stDocName, , , stLinkCriteria > >> Exit_opennextform_Click: > >> Exit Sub > >> Err_opennextform_Click: > >> MsgBox Err.Description > >> Resume Exit_opennextform_Click > >> End Sub > >> thanks soooo much for looking at this
|
Tue, 05 Nov 2002 03:00:00 GMT |
|
|
|